Hi, I am new at this so I need all the help I can get.
I am working on a program where the user enters a number into a text box. Then they press a button which adds the number to a list box. I have finally got the numbers to total in the list box (by clicking a button to calculate), but then when you click the Remove button, it removes the number from the list box, but does not remove it from the total.
Also, I can't figure out how to return the highest number in the list, the lowest number and the average of the numbers. I want these displayed in labels.
Here is some of my code:
PrivateSub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim I AsInteger
Dim decTotGrade AsDecimal
Dim Grades AsDecimal
Dim Count AsInteger
ForEach I In lstGradeList.Items
decTotGrades += I
Count = Val(lstGradeList.Items.Count)
If Count = Count - 1 Then
decTotGrade -= I
EndIf
Label4.Text = decTotGrades
PrivateSub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
Dim Count AsInteger
Dim I AsInteger
Dim TotGrade AsDecimal
lstGradeList.Items.Remove(lstGradeList.SelectedItem)
Count = Count - 1
If Count = Count - 1 Then
decTotGrades -= I
EndIf
Thanks for the help.
I am working on a program where the user enters a number into a text box. Then they press a button which adds the number to a list box. I have finally got the numbers to total in the list box (by clicking a button to calculate), but then when you click the Remove button, it removes the number from the list box, but does not remove it from the total.
Also, I can't figure out how to return the highest number in the list, the lowest number and the average of the numbers. I want these displayed in labels.
Here is some of my code:
PrivateSub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim I AsInteger
Dim decTotGrade AsDecimal
Dim Grades AsDecimal
Dim Count AsInteger
ForEach I In lstGradeList.Items
decTotGrades += I
Count = Val(lstGradeList.Items.Count)
If Count = Count - 1 Then
decTotGrade -= I
EndIf
Label4.Text = decTotGrades
PrivateSub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
Dim Count AsInteger
Dim I AsInteger
Dim TotGrade AsDecimal
lstGradeList.Items.Remove(lstGradeList.SelectedItem)
Count = Count - 1
If Count = Count - 1 Then
decTotGrades -= I
EndIf
Thanks for the help.