View Full Version : Max() problem

10-25-2003, 06:13 AM
How can I determine the highest value from 3 seperate values from 3 seperate tables.
a = rs(0)

d = max(a,b,c)

Roy Sinclair
10-27-2003, 05:09 PM
Since VBScript used in ASP doesn't have a built-in Max function:


10-27-2003, 10:30 PM
Thanks roy, In the end I just used a sorting routine, but what drag, just to return the highets of 3 numbers.
Im glad to see that Im not the only one hit here

10-29-2003, 11:20 AM
Why do all that when you only have to do this? It took me 5 minutes to knock together, and handles as many values as you need. Deriving a Min() function from it would take seconds too...! :

Function Max(ValueArray)
Dim MaxIndex, N

'Initialise Max with the first value
Max = ValueArray(0)
MaxIndex = UBound(ValueArray)

'Only continue if there's more than one value
If MaxIndex > 0 Then
'And loop through the other values
For N = 1 To MaxIndex
If ValueArray(N) > Max Then Max = ValueArray(N)
End If
End Function

Response.Write Max(Array(-15,17,3,40,-5.25))


10-29-2003, 10:15 PM
thanks marcus thats nice and easy

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum