'********************************************************************
'*
'* Function aryFindMax
'*
'* Author: NetworkAdminKB.com
'* Created: 2006-06-01
'* Modified: 2006-06-01
'*
'* Purpose: Returns the largest value or the index of the largest value
'* in the given array.
'*
'* Input: aryAny = The array to search for the largest value.
'* blnIndex = A boolean indicating to return the index
'* instead of the value.
'* True = Return the index of the largest value
'* False = Return the largest value (Default).
'*
'* Output: Returns the largest value or the index of the largest value.
'*
'* Notes: Works with numbers and strings.
'*
'********************************************************************
Function aryFindMax(ByVal aryAny, ByVal blnIndex)
'Version: 1.0 2006-06-01
Dim intMax, intIndex, x
If IsEmpty(blnIndex) Then blnIndex = False
intMax = aryAny(0)
intIndex = 0
For x = 0 to UBound(aryAny)
If aryAny(x) > intMax Then
intMax = aryAny(x)
intIndex = x
End If 'anyAny(x) > intMax
Next 'x
If blnIndex Then
aryFindMax = intIndex
Else
aryFindMax = intMax
End If 'blnIndex
End Function 'aryFindMax
Article ID: 109, Created On: 9/17/2011, Modified: 9/17/2011