I am currently working on an application where the user inputs 10 integers into an array and then clicks a button to display the integers in ascending or descending order from highest to lowest, however it is not working as intended. When I click the button that should sort them, nothing happens. Can anyone give some insight? Here is my current code.
Function intInput() As Integer
Const intMax As Integer = 9
Dim intArray(intMax) As Integer
Dim intCount As Integer 'Loop counter
For intCount = 0 To intMax 'Run intCount through intMax 10 times
intArray(intCount) = CInt(InputBox("Please enter an integer: ")) 'input the integers and store them into the array element
Next
lstArray.Items.Clear()
For intCount = 0 To intMax
lstArray.Items.Add(intArray(intCount)) 'add the integers to the list
Next
Return intArray(intCount)
End Function
Function intHighest() As Integer
Const intMax As Integer = 9
Dim intArray(intMax) As Integer
Dim intCount As Integer 'Loop counter
Dim intHigh As Integer
intHigh = intArray(0)
For intCount = 1 To (intArray.Length - 1)
If intArray(intCount) > intHigh Then
intHigh = intArray(intCount)
End If
Next
Return intHigh
End Function
Function intLow() As Integer
Const intMax As Integer = 9
Dim intArray(intMax) As Integer
Dim intCount As Integer 'Loop counter
Dim intLowest As Integer
intLowest = intArray(9)
For intCount = 1 To (intArray.Length - 1)
If intArray(intCount) < intLowest Then
intLowest = intArray(intCount)
End If
Next
Return intLowest
End Function
Private Sub btnInput_Click(sender As Object, e As EventArgs) Handles btnInput.Click
intInput()
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
lstArray.Items.Clear()
End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
intHighest()
intLow()
End Sub
End Class