我的累加器(decTotalCredits)无法正常工作,并且每个条目都重置为零。我需要累加器添加每个用户输入,直到它达到125.通常情况下,我确定它是小的东西。在此先感谢您的帮助!
' Declaring variable for Credit Entered by User
Dim decCredit As Decimal = CDec(txtCredit.Text)
' Declaring the accumulator
Dim decTotalCredits As Decimal
If IsNumeric(txtCredit.Text) Then
decCredit = Convert.ToDecimal(txtCredit.Text)
Select Case decCredit
Case Is = 5
Case Is = 10
Case Is = 25
Case Is = 100
Case Else
MsgBox("Please enter a valid coin amount", , "Invalid Amount Entered")
End Select
If decTotalCredits < 125 Then
decTotalCredits += decCredit
lblTotal.Text = CStr(decTotalCredits)
lblTotal.Visible = True
txtCredit.Clear()
txtCredit.Focus()
Else
' Once the credits are reached the prompt to make selection is visible.
lblMakeSelection.Visible = True
' Once the credits are reached, the buttons for selection become enabled.
btnDietPepsi.Enabled = True
btnPepsi.Enabled = True
btnSierraMist.Enabled = True
btnLemonade.Enabled = True
btnDrPepper.Enabled = True
btnWater.Enabled = True
End If
Else
MsgBox("Please enter a valid Coin amount", , "Input Error")
End If
答案 0 :(得分:3)
它被重新宣布..