Question calculate golf handicap

Joined
Feb 13, 2009
Messages
12
Programming Experience
3-5
Hi,
I am working on a little golf program and I need some help. I have to evaluate 5 scores, drop the high and low scores then average the three remaining ones. The result will be the Handicap. Note that there will be high scores with the same value as well as low scores with the same value.
Example:
Round_1 = 36
Round_2 = 43
Round_3 = 42
Round_4 = 36
Round_5 = 43
Need to drop one 36 and one 43
I am pulling the results from a datagridview. (No help needed there!)

Thanks in advance,
 
Thanks I got It

Public Module MyHandicap
Function GetHandi(ByVal Score1, ByVal Score2, ByVal Score3, ByVal Score4, ByVal Score5) As Integer
Dim Handicap As Integer
Dim myArray() As Integer = {Score1, Score2, Score3, Score4, Score5}
Array.Sort(myArray)
Handicap = (myArray(2) + myArray(3) + myArray(4)) / 3 * 0.95
Return Handicap
End Function
 
Last edited:
Double check your array indexers there? In an array of size 5 elements, the "middle 3" elements are not at indexes 2, 3, and 4. Also, this was not an ADO.net question

Arrays in VB .NET
 
Back
Top