Re: Price Data Formatting
- From: "Mike Williams" <mikea@xxxxxxxxxxxxxxxxx>
- Date: Tue, 19 Aug 2008 20:13:27 +0100
"Webbiz" <noreply@xxxxxxx> wrote in message news:ewH%23BUiAJHA.3952@xxxxxxxxxxxxxxxxxxxxxxx
Hi Mike. Thanks for your comments. Yes, I understand how
the Format() function works. The exercise here, however, is
that the data format is NOT KNOWN during design time but is based on the format of the data loaded during runtime.
The thing is you have not yet given us sufficient information about what you are doing. For example, in what format is the data as you are loading it in. Is it being loaded as a floating point value (Single or Double or whatever) is is it being loaded as a formatted string? Perhaps if you post a snippet oif code showing where you are loading this data from and exactly how you are loading it we might be in a better position to help.
Another example of where more information is needed is regarding your statement when you said, "For example, if the program loads in data that appears to be 'MOSTLY' one digit to the left of the decimal and 3 to the right, I want all numbers that result from any calculations on this data to also be in the same format [with three decimal places]". Do you really mean that? It sounds a bit odd to me. For example, suppose you test a set of incoming data and you discover that 10 values have two decimal places and 48 values have three decimal places and 32 values have four decimal places. In this cases the data MOSTLY has three decimal places. Do you REALLY want to truncate ALL displayed values so that they all have three decimal places, missing off the fourth decimal digit from the 32 values that originally had four digits? It does not sound at all like the right thing to do if you want my opinion. In the specific example I have just described I would personally show all values to four decimal places. In other words, perhaps you should be looking for the MAXIMUM number of decimal digits in the data items, ignoring "odd balls" that have a lot more than the average (such as the odd 1.2344999999989 that might creep in somewhere).
The other thing we have asked that you haven't yet provided an answer to is *where are you displaying the resultant output*. This is VERY important, as we cannot give much useful advice unless we know how you are displaying it. For example, are you printing the ouput using Print statements (perhaps to a Form or a PictureBox or a Printer) or are you placing it in some sort of control, such as a TextBox or a ListBox? Perhaps you woud like to answer that question?
My advice, regardless of where you are displaying the data, is to display it in such a way that the decimal point is set in a fixed position and the "whole part" of the number is displayed right aligned to the left of the decimal point with the decimal part displayed left aligned to the right of it, and with sufficient trailing zeros to accommodate however many decimal digits you have decided to display. But the best method of doing this will vary greatly, depending on your output device and the font you wish to use, which you haven't yet told us about.
Mike
.
- Follow-Ups:
- Re: Price Data Formatting
- From: Webbiz
- Re: Price Data Formatting
- References:
- Price Data Formatting
- From: Webbiz
- Re: Price Data Formatting
- From: Mike Williams
- Re: Price Data Formatting
- From: Webbiz
- Price Data Formatting
- Prev by Date: Windows 2003 & SrvAny.exe
- Next by Date: Re: Windows 2003 & SrvAny.exe
- Previous by thread: Re: Price Data Formatting
- Next by thread: Re: Price Data Formatting
- Index(es):
Relevant Pages
|