Gustav Brock
gustav at cactus.dk
Sun Nov 4 16:54:17 CST 2007
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