From: Rick Rothstein on
Yep, that is why I added the last sentence/question. It was not entirely
clear to me what Webbiz meant by "based on the way the values are formatted
in the array to begin with".

--
Rick (MVP - Excel)


"Larry Serflaten" <serflaten(a)usinternet.com> wrote in message
news:03F44C2F-9AF9-4FE9-9CAA-C87195AB2092(a)microsoft.com...
>
>
> "Rick Rothstein" <rick.newsNO.SPAM(a)NO.SPAMverizon.net> wrote
>>> BTW, while you've no problem 'nitpicking' <g>, got any suggestions on
>>> a snazy way to set the format pattern of the "#.####" based on the way
>>> the values are formatted in the array to begin with?
>>
>> Just put 15 # signs after the decimal point and VB will do the rest... it
>> will maintain the maximum number of decimal places that are required. One
>> thing you may want to consider (as long as you are using dots for decimal
>> places and no thousands separators in your Format pattern) is to wrap the
>> Format function's result with a Val function call... this will remove the
>> trailing dot in case the average comes out to be an integer result. Or
>> did you ask that because you want to preserve trailing zeroes in case the
>> result had less decimal places than the number with the most decimal
>> places that was being averaged?
>
> In some cases, trailing zeros are important...
>
> :-)
> LFS

From: Webbiz on
On Tue, 01 Dec 2009 08:53:00 +0000, Dee Earley
<dee.earley(a)icode.co.uk> wrote:

>On 01/12/2009 06:48, Webbiz wrote:
>> On Mon, 30 Nov 2009 21:21:52 -0500, "MikeD"<nobody(a)nowhere.edu> wrote:
>>> "Webbiz"<nospam(a)noway.com> wrote
>>>> Private Function DisplayAvgATR(ByRef Ranges() As Single) As String
>>
>> BTW, while you've no problem 'nitpicking'<g>, got any suggestions on
>> a snazy way to set the format pattern of the "#.####" based on the way
>> the values are formatted in the array to begin with?
>
>The values in the array wont have a format as they are Singles.
>Formatting only applies when you convert to a string for display purposes.
>If you want the caller to be able to control the output format, either
>return a single and let it format it or take the format string as a
>parameter.


I'm sorry, I didn't explain myself well.

The data in the array is of a particular format although Singles.
Stock and Commodity prices come in various formats. Here are some
common ones:

Currencies:

0.9244 Australian Dollar
1.6638 British Pound
0.9581 Canadian Dollar
1.5093 Euro
1.1539 Japanese Yen

Meats:

82.625 Live Cattle
59.200 Lean Hogs

Softs:

70.31 Cotton
142.75 Coffee
22.17 Sugar

Financials:

122.31250 30yr T Bonds

Indexes:

1108.80 SP500

Grains:

399.75 Corn
1059.50 Soybeans
562.50 Wheat

Actual prices at the time of writing this. :-)

So when one of these data files are loaded in, the output displays
would need to display results that are also in the appropriate format.

:-)

Webbiz

From: Webbiz on
On Tue, 1 Dec 2009 03:55:54 -0500, "Rick Rothstein"
<rick.newsNO.SPAM(a)NO.SPAMverizon.net> wrote:

>> BTW, while you've no problem 'nitpicking' <g>, got any suggestions on
>> a snazy way to set the format pattern of the "#.####" based on the way
>> the values are formatted in the array to begin with?
>
>Just put 15 # signs after the decimal point and VB will do the rest... it
>will maintain the maximum number of decimal places that are required. One
>thing you may want to consider (as long as you are using dots for decimal
>places and no thousands separators in your Format pattern) is to wrap the
>Format function's result with a Val function call... this will remove the
>trailing dot in case the average comes out to be an integer result. Or did
>you ask that because you want to preserve trailing zeroes in case the result
>had less decimal places than the number with the most decimal places that
>was being averaged?

Hello Rick.

My response to Dee's post may explain it better. But even a whole
number may require the decimal point if the original data format
requires it.

For example, if the data is for Soybeans, it would have two digits
following the decimal point even if the value is an integer, such as
1059.00.

Thanks!

Webbiz
From: Jeff Johnson on
"Webbiz" <nospam(a)noway.com> wrote in message
news:bttah5hon83ti9i7qrsudkr5or3mh8qrno(a)4ax.com...

> My response to Dee's post may explain it better. But even a whole
> number may require the decimal point if the original data format
> requires it.
>
> For example, if the data is for Soybeans, it would have two digits
> following the decimal point even if the value is an integer, such as
> 1059.00.

You need more than an array of <some basic data type>. What you need is an
array of classes or stuctures (VB Types) which have properties that further
define the value you're storing.


From: Mike Williams on

"Webbiz" <nospam(a)noway.com> wrote in message
news:bttah5hon83ti9i7qrsudkr5or3mh8qrno(a)4ax.com...

> For example, if the data is for Soybeans, it would have two
> digits following the decimal point [and hogs would have three]
> even if the value is an integer, such as 1059.00.

Dim LeanHogs As Single, Soybeans As Single
LeanHogs = 59
Soybeans = 1059
Print Format(LeanHogs, "0.000")
Print Format(Soybeans, "0.00")

Mike