I am working on a class project that calls for a test score calculator that calculates and displays the score total, score count, and average score. If the user clicks the Display scores button, the application sorts the scores and displays them in a message box. There is also a Clear button to have all entries removed. And an exit button.

I had worked on this for hours and I was just told that I'm doing it all wrong. This is my first major vb project. I need some help with this as the project is due tomorrow. Thanks

Here is what I have so far.

Public Class Form1
Dim highScore As Integer
Dim Score As Integer
Dim totalScore As Integer
Dim numberScores As Integer

Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
Score = txtTestScore.Text
totalScore = totalScore + Score
numberScores = numberScores + 1
If (Score > highScore) Then
highScore = Score
End If
txtBest.Text = highScore
Dim averageScore As Decimal = Math.Round(totalScore / numberScores, 2)
txtAverage.Text = averageScore
End Sub

End ClassPublic Class Form1
Dim highScore As Integer
Dim Score As Integer
Dim totalScore As Integer
Dim numberScores As Integer

Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
Score = txtTestScore.Text
totalScore = totalScore + Score
numberScores = numberScores + 1
If (Score > highScore) Then
highScore = Score
End If
txtBest.Text = highScore
Dim averageScore As Decimal = Math.Round(totalScore / numberScores, 2)
txtAverage.Text = averageScore
End Sub

End Class

I think you miss to store the scores. To do that, you can use a Specialized Collection of OrderedDictionary strings.
The collection's method add permits you to store the scores in the collection.
The collection's method clear permits you to clear all the contents of the collection.

The help on this kind of collection has examples on how to add, clear, remove and retrieve the collection items.

Hope this helpd

Had started all over again (see code). Stuck right now. Need help

Public Class Form1

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        End
    End Sub
    Dim lNumbers As List(Of Integer) = New List(Of Integer)
    Dim highScore As Integer
    Dim Score As Integer
    Dim totalScore As Integer
    Dim numberScores As Integer
    Dim averageScore As Decimal

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

        If TextBox1.Text >= 0 And TextBox1.Text <= 100 Then
            lNumbers.Add(TextBox1.Text)
            Score = TextBox1.Text
            totalScore = totalScore + Score
            numberScores = numberScores + 1
            lblScoreCount.Text = numberScores

            If (Score > highScore) Then
                highScore = Score
            End If

            lblScoreTotal.Text = totalScore
            averageScore = Math.Round(totalScore / numberScores, 2)
            lblAverage.Text = averageScore
        Else
            MessageBox.Show("Score must be between 0 and 100")
        End If

    End Sub

    Private Sub btnCS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCS.Click
        lblAverage.Text = ""
        lblScoreCount.Text = ""
        lblScoreTotal.Text = ""
        TextBox1.Text = ""
        lNumbers.Clear()
        totalScore = 0
        numberScores = 0
        averageScore = 0

    End Sub

    Private Sub btnDS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDS.Click
        lNumbers.Sort()
        MessageBox.Show(lNumbers.Item(0).ToString + lNumbers.Item(1).ToString)



    End Sub
End Class

I just cant get the display score function (btnDS) to display all the scores entered.

May be you can try

Private Sub btnDS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDS.Click
        lNumbers.Sort()
        Dim MessageToShow as String
        For I as Integer = 0 to lNumbers.Count
            MessageToShow &= "Score " & (I + 1).Tostring & ": " & lNumbers.Item(I).Tostring & ControlChars.CrLf
        Next
        MessageToShow &= ControlChars.CrLf & "Total: " & totalScore.ToString & ControlChars.CrLf
        MessageToShow &= "Average: " & averageScore.ToString
        MessageBox.Show(MessageToshow)
    End Sub

Hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.