我应该为足球比赛的编程作业制作分数计算器。它有 4 个文本框和一个按钮,该功能需要有完整的信用,我只是不确定我做错了什么。
Public Class Form1
Dim intTotal = 0
Dim intFirst = 0
Dim intSecond = 0
Dim intThird = 0
Dim intFourth = 0
Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
Try
Dim intFirst As Integer = Convert.ToInt32(txtFirst.Text)
Dim intSecond As Integer = Convert.ToInt32(txtSecond.Text)
Dim intThird As Integer = Convert.ToInt32(txtThird.Text)
Dim intFourth As Integer = Convert.ToInt32(txtFourth.Text)
Catch ex As Exception
MessageBox.Show("Enter in Digits!")
End Try
intTotal = calcTotal(intFirst, intSecond, intThird, intFourth, intTotal)
Me.lblTotal.Text = intTotal 'Shows as 0 at run-time
End Sub
Function calcTotal(ByVal intFirst As Integer, ByVal intSecond As Integer, ByVal intThird As Integer, ByVal intFourth As Integer, ByVal intTotal As Integer) As Integer
intTotal = intFirst + intSecond + intThird + intFourth
Return intTotal
End Function
End Class
lblTotal
最终显示为 0。