Hello All,
I am really confused on how to get the second highest value in a Access VBA array. I can get the highest value with the below code from the Microsoft website, but I can't find how to get the second and third highest values in different functions.
Function Maximum(ParamArray FieldArray() As Variant)
' Declare the two local variables.
Dim I As Integer
Dim currentVal As Variant
' Set the variable currentVal equal to the array of values.
currentVal = FieldArray(0)
' Cycle through each value from the row to find the largest.
For I = 0 To UBound(FieldArray)
If FieldArray(I) > currentVal Then
currentVal = FieldArray(I)
End If
Next I
' Return the maximum value found.
Maximum = currentVal
End Function
Thank you in advance.
kaprmg
I am really confused on how to get the second highest value in a Access VBA array. I can get the highest value with the below code from the Microsoft website, but I can't find how to get the second and third highest values in different functions.
Function Maximum(ParamArray FieldArray() As Variant)
' Declare the two local variables.
Dim I As Integer
Dim currentVal As Variant
' Set the variable currentVal equal to the array of values.
currentVal = FieldArray(0)
' Cycle through each value from the row to find the largest.
For I = 0 To UBound(FieldArray)
If FieldArray(I) > currentVal Then
currentVal = FieldArray(I)
End If
Next I
' Return the maximum value found.
Maximum = currentVal
End Function
Thank you in advance.
kaprmg