[AccessD] highest value of 4 variables - urgent

Kath Pelletti kp at sdsonline.net
Mon Nov 5 17:13:10 CST 2007


thanks Gustav - I have never really mastered arrays in vba (used to use them 
a lot in Cobol, RPG - but many moons ago).

So thanks to you and John for the examples.

Kath
----- Original Message ----- 
From: "Gustav Brock" <gustav at cactus.dk>
To: <accessd at databaseadvisors.com>
Sent: Monday, November 05, 2007 9:54 AM
Subject: Re: [AccessD] highest value of 4 variables - urgent


> Hi Kath
>
> I'm with JC. This is an excellent example to demonstrate the power of 
> ParamArray. Here's an example specific for dates that I have used:
>
> Public Function DateMax(ParamArray avarDates() As Variant) As Date
>
> ' Return maximum date/time value of elements in
> ' array avarDates().
> ' If no elements of array avarDates() are dates,
> ' value of cdatEmpty is returned.
> '
> ' 2003-09-30. Cactus Data ApS, CPH.
>
>  ' Return value for an empty array.
>  Const cdatEmpty As Date = #1/1/100#
>
>  Dim varDate     As Variant
>  Dim varDateMax  As Variant
>
>  For Each varDate In avarDates()
>    If IsDate(varDate) Then
>      If VarType(varDate) <> vbDate Then
>        varDate = CDate(varDate)
>      End If
>      If varDate > varDateMax Then
>        varDateMax = varDate
>      End If
>    End If
>  Next
>
>  If IsEmpty(varDateMax) Then
>    varDateMax = cdatEmpty
>  End If
>
>  DateMax = varDateMax
>
> End Function
>
> /gustav
>
>
>>>> kp at sdsonline.net 03-11-07 23:57 >>>
> maybe i am having a vague moment - but what function can I use to get the 
> highest value of 4 variables, eg:
>
>
> eg. I want to know x where x is the highest of (var1, var2, var3, var4)
>
> ta
> ______________________________________
> Kath Pelletti
>
>
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 





More information about the AccessD mailing list