好的,所以我的累加器現在可以在表單中正確添加和顯示。然而,在我的if ... then語句中出現了一些錯誤,並且在達到125後沒有將它扔到第二級。我可以打125,我需要輸入一個條目才能啓用我的按鈕。任何幫助表示讚賞!我的累加器和計算不能在VB 2010中工作
* 編輯顯示用Do While Loop進行更新。現在造成的問題與我輸入錯誤的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
在添加當前信用額度之前,您正在檢查總信用額度。 – Ryan 2012-04-13 00:17:20
謝謝......我已經將原來的IF語句更改爲Do While Loop ...現在給我的msgbox發出錯誤......他們彈出並且不允許輸入新數據......這是「INPUT錯誤「,這給我帶來麻煩 – 2012-04-13 00:33:48
爲什麼它在一個循環?這是保證現在不工作... – Ryan 2012-04-13 00:46:40