0

これで、アキュムレータが追加され、合計としてフォームに適切に表示されるようになりました。ただし、if... then ステートメントに何か問題があり、125 に達した後、2 番目のレベルにスローされません。125 をヒットでき、ボタンを有効にするためにエントリを作成する必要があります。どんな助けでも大歓迎です!

* Do While ループで更新された表示に編集します。入力エラーメッセージボックスで問題が発生しています... *

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
4

1 に答える 1

1

あなたが私たちに与えたコードから、それはループに入り、合計に追加し、txtCreditテキストボックスを消去し、ループを再び開始し、エラーメッセージボックスを表示します.txtCreditはもはや数値ではありません.

ロジックがボタン クリックまたは TextBox Validate ルーチンにあると仮定すると、ループを削除し、ボタンを有効にする前に "If decTotalCredit >= 125 Then " ステートメントを追加することをお勧めします。

于 2012-04-13T03:07:34.657 に答える