Hello, we have to create a football scoreboard in Visual Basic.
Purpose: The application calculates the points scored during a football game by one team


  1. The user clicks the enter score button in an input box object to enter a score after the football team scores
  2. Each score and running total are displayed in a list box
  3. After the user clicks the cancel button in the input box object to end the game scoring the total final score is displayed
  4. A file menu with a clear (clears scores and results) and exit (closes app)


  1. Non numeric values shall not be accepted
  2. Negative value should not be accepted

I am really struggling in this class so I used some example code for another project from the book. The first problem I'm having is when I go and run the program and type in the first number I get the negativenumber error. I'm also not sure if the program will actually run (again I am very lost in the class) If anyone could take a look and tell me where I am going wrong I would really appreciate it.
Thank you.

Public Class footballfever

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuexit.Click
    End Sub

    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuclear.Click
        lblfinalscore.Visible = False
        btnEnterScore.Enabled = True
    End Sub

    Private Sub btnEnterScore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnterScore.Click

        Dim strscore As String
        Dim decscore As Decimal
        Dim decfinalscore As Decimal = 0D
        Dim strinputboxmessage As String = "enter the score for game #"
        Dim strinputboxheading As String = "football score"
        Dim strnormalboxmessage As String = "enter the score for game #"
        Dim strnonnumericerror As String = " Error - enter a number for the score #"
        Dim strnegativeerror As String = "Error please enter a positive number for score #"
        Dim dectotalscore As Decimal
        Dim strcancelbuttonclicked As String = ""
        Dim intmaxnumberofentries As Integer = 10
        Dim intnumberofenteries As Integer = 1

        strscore = InputBox(strinputboxmessage & intnumberofenteries, _
        strinputboxheading, " ")
            Do Until intnumberofenteries > intmaxnumberofentries _
            Or strscore = strcancelbuttonclicked

                If IsNumeric(strscore) Then
                    decfinalscore = Convert.ToDecimal(strscore)
                    If decscore > 0 Then
                        decfinalscore += decscore
                        intnumberofenteries += 1
                        strinputboxmessage = strnormalboxmessage
                        strinputboxmessage = strnegativeerror

                    End If

                    strinputboxmessage = strnonnumericerror
                End If

                If intnumberofenteries <= intmaxnumberofentries Then
                    strscore = InputBox(strinputboxmessage & intnumberofenteries, _
                    strinputboxheading, " ")
                End If
            lblfinalscore.Visible = True

            If intnumberofenteries > 1 Then
                decfinalscore = dectotalscore + decscore
                lblfinalscore.Text = "Average score per game is " & _
                decfinalscore.ToString("F1") & "average score"
                Me.lblfinalscore.Text = "no score entered"

            End If
            btnEnterScore.Enabled = False


    End Sub

End Class

I don't know if this is right? Please check for me please and thank you!

You aren't setting the decstore variable to be any value so when you try
If decscore > 0 Then
it failing because decstore isn't greater than zero. I think that piece of logic is incorrect but it all depends on what you expect decstore to be I guess.

This article has been dead for over six months. Start a new discussion instead.