Visual Basics Problem: Soccer Team Score Application Suppose a soccer team needs
ID: 3820660 • Letter: V
Question
Visual Basics Problem:
Soccer Team Score Application
Suppose a soccer team needs an application to record the number of points scored by its players during a game. Create an application that asks how many players the team has and then asks for the name of each player. The program should declare an array of strings large enough to hold the player names and declare an array of integers large enough to hold the number of points scored by each player. The application should have a menu system or buttons that perform the following:
Display the form allowing the user to enter the player’s names.
Display a form that can be used during a game to record the points scored by each player.
Display the total points scored by each player and the team.
Input Validation: Do not accept negative numbers as points
Explanation / Answer
Public Class FootballScoreboard
Private Sub EnterScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnterScore.Click
Dim strScore1 As String
Dim intScore1 As Integer
Dim intTotalScore1 As Integer
Dim intFinalScore1 As Integer = 0D
Dim strInputMessage1 As String = "Enter the score #"
Dim strInputHeading1 As String = " SCORE"
Dim strNormalMessage1 As String = "Enter the score #"
Dim strNonNumericError1 As String = " Error - please enter the number for score #"
Dim strNegativeError1 As String = "Error : please enter the positive number for the score #"
Dim strCancelClicked1 As String = ""
Dim intMaxNumberOfEntries1 As Integer = 100
Dim intNumberOfEntries1 As Integer = 1
strScore1 = InputBox(strInputMessage1 & intNumberOfEntries1, strInputHeading1, " ")
Do Until intNumberOfEntries1 > intMaxNumberOfEntries1 Or strScore1 = strCancelClicked1
If IsNumeric(strScore1) Then
intScore1 = (strScore1)
If intScore > 0 Then
lstScore.Items.Add(intScore1)
intFinalScore1 += intScore1
intNumberOfEntries1 += 1
strInputMessage1 = strNormalMessage1
Else
strInputMessage1 = strNegativeError1
End If
Else
strInputMessage1 = strNonNumericError1
End If
If intNumberOfEntries1 <= intMaxNumberOfEntries1 Then
strScore1 = InputBox(strInputMessage1 & intNumberOfEntries1, strInputHeading1, " ")
End If
Loop
' let FinalScore be visible.
lblFinalScore.Visible = True
' Determines/decide the game score.
If intNumberOfEntries1 > 1 Then
intFinalScore1 = intTotalScore1 + intScore1
FinalScore.Text = "Total score is " & _
intFinalScore1.ToString("F1")
Else
FinalScore.Text = "No score entered"
End If
' enable the Enter Score.
EnterScore.Enabled = False
End Sub
lstScore.Items.Clear()
FinalScore.Visible = False
EnterScore.Enabled = True
End Sub
Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
'The mnuExit click event will closes the windows even exits the application.
Close()
End Sub
End Class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.