From: Larry Serflaten on
On Dec 2, 6:33 am, "Jim Mack" <jm...(a)mdxi.nospam.com>

> Any value you see on the screen is a string.


Unless its part of an image...

<g>
LFS
From: Mike Williams on

"Larry Serflaten" <serflaten(a)gmail.com> wrote in message
news:97841fc5-3f85-47ee-9f0c-18ac29452e80(a)o23g2000vbi.googlegroups.com...
On Dec 2, 6:33 am, "Jim Mack" <jm...(a)mdxi.nospam.com>
> >Any value you see on the screen is a string.

> Unless its part of an image... <g>
LFS

Oh, go on then, let's be pedantic . . . /everything/ you see on the screen
is an image :-)

.. . . unless its a thumb print of course, or a little splash of coffee ;-)

Mike


From: deactivated on
On Mon, 30 Nov 2009 21:21:52 -0500, "MikeD" <nobody(a)nowhere.edu>
wrote:

>And one more nitpick. Your function is making an assumption that the passed
>in array will be 0-based. That's probably OK since that's the default for an
>array. But you can make it generic so that it will work regardless of what
>the lower bound is by doing this:
>
>Private Function CalcAvg(ByRef Ranges() As Single) As String
>Dim n As Long
>Dim sngTotal As Single
>Dim sngAvg As Single
>
> For n = LBound(Ranges) To UBound(Ranges)
> sngTotal = sngTotal + Ranges(n)
> Next n
>
>
>
> 'Return the Average
> sngAvg = sngTotal / (UBound(Ranges) - LBound(Ranges) + 1)
> CalcAvg = Format$(sngAvg, "#.######")
>
>End Function
>
>
>And one last nitpick, since the function returns a String, use the String
>version of the Format function, as shown above.
>
>Some people will even say there's no need for the sngAvg variable. Just do
>this:
>
>CalcAvg = Format$(sngTotal / (UBound(Ranges) - LBound(Ranges) + 1),
>"#.######")

Making sure that there are items in the array, else you will have a
div by 0 error, and the sum of all items is >0.

Heh, might as well deeply nitpick...
>
>And strictly speaking they'd be right. There is no absolute reason to use a
>local variable to hold the result of the calculation, but when I'm debugging
>and stepping through code, I like to have the results of calculations
>assigned to variables to make it easier to get a tooltip of the result of
>that calculation in the IDE (and yes I know you could position the
>mousepointer on an opening parenthesis or select the expression to get a
>tooltip showing the result, but it's much easier to just position the
>mousepointer within a variable name). And the millisecond (or less) that the
>local variable is using memory...not an issue as far as I'm concerned.
>
>--
>Mike
>
>
>

From: deactivated on
On Tue, 01 Dec 2009 00:48:11 -0600, Webbiz <nospam(a)noway.com> wrote:

>On Mon, 30 Nov 2009 21:21:52 -0500, "MikeD" <nobody(a)nowhere.edu>
>wrote:

>>Private Function CalcAvg(ByRef Ranges() As Single) As String
>>Dim n As Long
>>Dim sngTotal As Single
>>Dim sngAvg As Single
>>
>> For n = LBound(Ranges) To UBound(Ranges)
>> sngTotal = sngTotal + Ranges(n)
>> Next n
>>
>>
>>
>> 'Return the Average
>> sngAvg = sngTotal / (UBound(Ranges) - LBound(Ranges) + 1)
>> CalcAvg = Format$(sngAvg, "#.######")
>>
>>End Function

Should not a function do a single thing?

Like calculate an average and return in the same type.

Any user who wants to format the result can then put it in another
function that would format the string.

That way the user can reuse that average function elsewhere as it is
almost generic.
From: Jim Mack on
Larry Serflaten wrote:
> On Dec 2, 6:33 am, "Jim Mack" <jm...(a)mdxi.nospam.com>
>
>> Any value you see on the screen is a string.
>
>
> Unless its part of an image...
>
> <g>


I considered that as I posted but thought... naw, no one would go
there. (-:

--
Jim