我尝试使用 CInt、TryParse、Convert.Int32 等进行转换,但没有任何效果。我只需要在单击按钮 btnVote 时显示候选人的总票数,并在单击 btnResult 时显示结果。我也尝试在网上搜索,但仍然没有运气,所以我来到了这个网站,希望我能用 VB.net 中的程序解决我的问题
下面是我的代码:
Public Class Presidential_Election
Private Sub btnVote_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVote.Click
If cboCandidates.Text = "NOLI" Then
lblNoli.Text = Integer.Parse(lblNoli.Text) + 1
ElseIf cboCandidates.Text = "VAL" Then
lblVal.Text = (CInt(lblVal.Text) + 1).ToString
ElseIf cboCandidates.Text = "LESTER" Then
lblLester.Text = CInt(lblLester.Text) + 1
ElseIf cboCandidates.Text = "GWAPO" Then
lblGwapo.Text = CInt(lblGwapo.Text) + 1
End If
End Sub
Private Sub btnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResult.Click
lblNoli.Visible = True
lblVal.Visible = True
lblLester.Visible = True
lblGwapo.Visible = True
End Sub
End Class