beta
11-19-2005, 08:52 AM
Is there any way to compare a set of varibles to find the one that contains the biggest number? and also the one that contains the 2nd biggest.
Thanks.
Thanks.
|
Click to See Complete Forum and Search --> : Comparing Variables beta 11-19-2005, 08:52 AM Is there any way to compare a set of varibles to find the one that contains the biggest number? and also the one that contains the 2nd biggest. Thanks. buntine 11-19-2005, 08:33 PM Write a function for such tasks. Place the variables into an array and then traverse the array constantly storing (and, if necessary, updating) the largest number. Make sense? Regards. Bullschmidt 11-24-2005, 02:06 AM Here's a related function that compares 2 numbers (and you may even want to search at Google or http://www.hotscripts.com or http://www.planet-source-code.com or http://www.scripts.com for an ASP max function that can handle an array of numbers: Function jpsvbMax(pvarNum1, pvarNum2) ' Purpose: Max. ' Remarks: Only currently accept two numbers. ' If either incoming item is not numeric, then return Null. ' Dim var. Dim varNum1 Dim varNum2 Dim varMax ' Quick exit if either item not numeric. If (Not IsNumeric(pvarNum1)) Or (Not IsNumeric(pvarNum2)) Then jpsvbMax = Null Exit Function End If ' Set var. varNum1 = CDbl(pvarNum1) varNum2 = CDbl(pvarNum2) ' Compare. If varNum1 > varNum2 Then varMax = pvarNum1 Else varMax = pvarNum2 End If ' Return val. jpsvbMax = varMax End Function webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |