Question: Please I need help with visual basic code . I have attached the files that I have done so far at the bottom of ths
Please I need help with visual basic code. I have attached the files that I have done so far at the bottom of ths request
2. Declare a module-level variable for an array that can hold up to 20 scores.
3. Modify the Click event handler for the Add button so it adds the score thats entered by the user to the next element in the array. To do that, you can use the score count variable to refer to the element.
4. Move the Clear Scores button as shown above. Then, modify the Click event handler for this button so it removes any scores that have been added to the array. The easiest way to do that is to create a new array and assign it to the array variable.
5. Add a Display Scores button that sorts the scores in the array, displays the scores in a dialog box, and moves the focus to the Score text box. Be sure that only the elements that contain scores are displayed.
6 Replace the declaration for the array variable with a declaration for a List(Of Integer) object, and delete the module-level variable for the score count.
7 Modify the Click event handler for the Add button so it adds the score thats entered by the user to the list. In addition, delete the statement that increments the score count variable you deleted. Then, declare a local variable to store the count, and assign the Count property of the list to this variable.
8. Modify the Click event handler for the Clear Scores button so it removes any scores that have been added to the list.
9. Modify the Click event handler for the Display Scores button so it sorts the scores in the list and then displays them in a dialog box.
Public Class Form1
Dim Score(2) As Integer
Dim Total As Integer Dim Count As Integer Dim Average As Double
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
For i As Integer = 0 To Score.GetUpperBound(0) Dim Input As Integer = CInt(tboScore.Text) Score(i) = Input Total += Score(i) Count += 1
tboScoreTotal.Text = CType(Total, String) tboScoreCount.Text = CType(Count, String) Average = (Total / Count) tboAverage.Text = CType(Average, String)
tboScore.Clear() Next
End Sub
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
tboScore.Text = CType(0, String) tboScoreTotal.Text = CType(0, String) tboScoreCount.Text = CType(0, String) tboAverage.Text = CType(0, String)
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
