Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Visual Basic Soccer Team Score Application Suppose a soccer team needs an applic

ID: 3762900 • Letter: V

Question

Visual Basic

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.

NOTE:

You should have 4 forms: MainForm, PlayerForm, PlayerPointsForm, GamePointsForm.

You should have 1 module: SoccerTeamModule – to hold any PUBLIC array or variable declarations that will be accessed by all forms in the application.

Explanation / Answer

First create a soccer class with name soccer and file name soccer.vb

Public Class Soccer

    Public soccerName As String

    Public score1 As Integer

    Public score2 As Integer

    Public score3 As Integer

    Public totalscore As Integer

End Class

Now Main form creation and design:

Add labels and textboxes to the form that are required.

Public Class Form1

    Dim n As Integer

    Dim count As Integer = 0

    Dim sc(10) As Soccer

    Dim total As Integer = 0

    Dim str As String = ""

    Public Function AddItems(ByVal val As Soccer)

        sc(count) = val

    End Function

   

    Private Sub okButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles okButton.Click

        n = Int(players.Text)

        For i As Integer = 1 To n

            sc(i) = New Soccer

        Next

        players.Enabled = False

    End Sub

    Private Sub addButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles addButton.Click

        Form2.Show()

        count = count + 1

        If count = n Then

            addButton.Enabled = False

        End If

    End Sub

    Private Sub scoreButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles scoreButton.Click

        str = "Name " & vbTab & vbTab & "   Total Score "

        Form3.ListBox1.Items.Add(str)

        For I As Integer = 1 To n

            str = sc(I).soccerName & vbTab & vbTab & vbTab & sc(I).totalscore.ToString

            Form3.ListBox1.Items.Add(str)

            total = total + sc(I).totalscore

        Next

        str = Environment.NewLine & "Overall Score: " & vbTab & total.ToString

        Form3.ListBox1.Items.Add(str)

        Form3.Show()

    End Sub

    Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click

Me.Close()

    End Sub

    Private Sub players_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles players.TextChanged

    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

End Class

Click on ok

And click on add player you will got Players and pointes form

Now Players and pointes form design and code:

Add labels and textboxes to the form that are required.

Public Class Form2

    Dim s As Soccer = New Soccer

      

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged

    End Sub

    Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged

    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        s.soccerName = TextBox1.Text

        s.score1 = CInt(TextBox3.Text)

        s.score2 = CInt(TextBox4.Text)

        s.score3 = CInt(TextBox2.Text)

        s.totalscore = CInt(TextBox3.Text) + CInt(TextBox4.Text) + CInt(TextBox2.Text)

        Form1.AddItems(s)

        Me.Close()

    End Sub

End Class

Click on add in the above form

And add player in main form