I'd write it like this:

 dim MyValues() as integer = IntegerValues(Days1, Days2, Days3, ... Days10)
 dim MyMin as integer = Min(MyValues)
 dim MyMax as integer = Max(MyValues)

Of course, this implies that I would also write these functions:

Function IntegerValues(paramArray EditFields as EditField) as integer()
 dim result() as integer
 for each field as EditField in EditFields
   result.Append val(field.text) // can check the text further for
validity here
 next field
 return result
End Function

Function Min(Values() as integer) as integer
 dim result as integer = Values(0)
 for i as integer = 1 to UBound(Values)
   result = Min(result, Values(i))
 next i
 return result
End Function

and similarly for Max. (Tip: You can create a new module and paste
these text blocks in, and RB will automatically parse out the name,
parameters, and return type. Unfortunately you have to do it one at a
time. These compile, but I haven't tested them thoroughly.)

Note that "Values(0)" in the Min and Max functions will fail if the
input array contains no elements, which is appropriate, since the
minimum value for an array that contains no elements is undefined. If
this is a realistic case, the caller should check for this first, or
the function could be adjusted to accept a default parameter for the
return value.

At first I might chafe at having to write three new functions, but I
would soon realize that two of them are generically useful, and I
would be happy to add them to my ever-growing RB code library.

lj
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to