好的,所以我的累加器现在正在添加并正确显示在表格中。但是,我的 if...then 语句有问题,在达到 125 后它没有将其扔到第二级。我可以达到 125,我需要输入以启用我的按钮。任何帮助表示赞赏!
*编辑以显示使用 Do While 循环更新。现在导致我的输入错误 msgbox 出现问题... *
do while decTotalCredits < 125
If IsNumeric(txtCredit.Text) Then
' This statement will convert the string entered to decimal and establish the
' input as the decCredit Variable
decCredit = Convert.ToDecimal(txtCredit.Text)
' This Case Statement is to verify that the correct denominations of coins are
' being entered in the machine.
Select Case decCredit
Case 5, 10, 25, 100
' This line adds the newly entered credit to the
' exsisting total
decTotalCredits += decCredit
lblTotal.Text = Convert.ToString(decTotalCredits)
lblTotal.Visible = True
' reset the text input box for the credit amount
txtCredit.Clear()
txtCredit.Focus()
Case Else
' This message will appear if a Credit is entered that does not
' conform to normal coins
MsgBox("Please enter a valid coin amount", , "Invalid Amount Entered")
End Select
Else
' This message will occur when a user inputs a non-numeric entry
MsgBox("Please enter a valid Coin amount", , "Input Error")
End If
Loop
' Loop should complete when credits hit 125 and activate this code
' 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 Sub