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
Requirements:
- The user clicks the enter score button in an input box object to enter a score after the football team scores
- Each score and running total are displayed in a list box
- After the user clicks the cancel button in the input box object to end the game scoring the total final score is displayed
- A file menu with a clear (clears scores and results) and exit (closes app)
Restrictions
- Non numeric values shall not be accepted
- 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
Close()
End Sub
Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuclear.Click
lstScoreBox.Items.Clear()
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
Do Until intnumberofenteries > intmaxnumberofentries _
Or strscore = strcancelbuttonclicked
If IsNumeric(strscore) Then
decfinalscore = Convert.ToDecimal(strscore)
If decscore > 0 Then
Me.lstScoreBox.Items.Add(decscore)
decfinalscore += decscore
intnumberofenteries += 1
strinputboxmessage = strnormalboxmessage
Else
strinputboxmessage = strnegativeerror
End If
Else
strinputboxmessage = strnonnumericerror
End If
If intnumberofenteries <= intmaxnumberofentries Then
strscore = InputBox(strinputboxmessage & intnumberofenteries, _
strinputboxheading, " ")
End If
Loop
lblfinalscore.Visible = True
If intnumberofenteries > 1 Then
decfinalscore = dectotalscore + decscore
lblfinalscore.Text = "Average score per game is " & _
decfinalscore.ToString("F1") & "average score"
Else
Me.lblfinalscore.Text = "no score entered"
End If
btnEnterScore.Enabled = False
Loop
End Sub
End Class
I don't know if this is right? Please check for me please and thank you!