在 Visual Studio 的 2019 年 (VB) 中创建成绩计算器并在代码上苦苦挣扎

Creating a Grade Calculator in Visual Studio's 2019 (VB) and struggling with the code a bit

我在Visual Studio 2019年使用VB.Net来帮助积累考试成绩数据。

我有一个名为 Score 的标签,Score TotalScore CountScore Average 的文本框都是只读的。我还按 AddClear 分数,以及 Exit.

我已经为“清除分数”和“退出”按钮完成了代码,但我正在努力使用“添加”按钮并获取所有分数的输入和总和。

我的目标是在 Score Total 框中显示所有分数的总和,在 Score Count 框中显示分数的数量,在 Score Average 框中显示它们的平均值。

这是我目前拥有的:

Public Class GradeCalculator
    Dim score As Integer
    Dim ScoreTotal As Decimal
    Dim ScoreCount As Decimal
    Dim Average As Integer

    Private Sub frmClearScores_Click(sender As Object, e As EventArgs) Handles frmClearScores.Click
        score = 0
        ScoreTotal = 0
        ScoreCount = 0
        Average = 0

        txtscore.Text = ""
        txtscoretotal.Text = ""
        txtscorecount.Text = ""
        txtaverage.Text = ""

        txtscore.Select()
    End Sub

    ' This is the "Add" button
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class

我怎样才能完成这个?

Public Class GradeCalculator
    Dim ScoreTotal As Integer = 0
    Dim ScoreCount As Integer = 0

    Private Sub frmClearScores_Click(sender As Object, e As EventArgs) Handles frmClearScores.Click
        ScoreTotal = 0
        ScoreCount = 0

        txtscore.Text = ""
        txtscoretotal.Text = ""
        txtscorecount.Text = ""
        txtaverage.Text = ""

        txtscore.Select()
    End Sub

    ' This is the "Add" button
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        ScoreTotal += CInt(txtscore.Text)
        ScoreCount += 1

        txtscore.Text = ""
        txtscoretotal.Text = ScoreTotal.ToString()
        txtscorecount.Text = ScoreCount.ToString()
        txtaverage.Text = (CDec(ScoreTotal)/ScoreCount).ToString()

        txtscore.Select()
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class