Ok thanks you guys for the help but now the rest of my program wont work :/
I get the following Error : ArguementOutOfRangerExceptin was unhandled. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Code:Private Sub btnDisplayLargestNumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayLargestNumber.Click Dim Largest As Integer Largest = MyArray(0) For J = 1 To 24 If MyArray(J) > Largest Then Largest = MyArray(J) End If Next txtDisplayNumbers.Text = CStr(Largest) End Sub Private Sub btnDisplaySmallestNumber_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplaySmallestNumber.Click Dim Smallest As Integer Smallest = MyArray(0) For J = 1 To 24 If MyArray(J) < Smallest Then Smallest = MyArray(J) End If Next txtDisplayNumbers.Text = CStr(Smallest) End Sub Private Sub btnDisplayRange_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayRange.Click Dim Smallest As Integer Dim Largest As Integer Smallest = MyArray(0) Largest = MyArray(0) For J = 1 To 24 If MyArray(J) < Smallest Then Smallest = MyArray(J) ElseIf MyArray(J) > Largest Then Largest = MyArray(J) End If Next txtDisplayNumbers.Text = _ CStr(Smallest) & " to " & CStr(Largest) End Sub Private Sub btnDisplaySumOfNumbers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplaySumOfNumbers.Click Dim Sum As Integer For J = 0 To 24 Sum = Sum + MyArray(J) Next txtDisplayNumbers.Text = CStr(Sum) End Sub Private Sub btnDisplayMean_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplayMean.Click Dim lCounter As Long Dim dTotal As Double Dim dAverage As Double dTotal = 0 For lCounter = 0 To UBound(Array) dTotal = dTotal + MyArray(CInt(lCounter)) Next dAverage = dTotal / (UBound(Array) + 1) txtDisplayNumbers.Text = CStr(dAverage) End Sub End Class




Reply With Quote
