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)
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...! :
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)
10-29-2003, 10:15 PM
thanks marcus thats nice and easy
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.