它突出显示 ##### 包围的部分是正确的,但我没有看到错误。
Private Sub UIDeposit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UIDeposit.Click
'Declear(NumberOfCoins)
Dim depositCash(7) As Integer
'coins as expessions
depositCash(COIN1P) = CInt(UIPence1.Text)
depositCash(COIN2P) = CInt(UIPence2.Text)
depositCash(COIN5P) = CInt(UIPence5.Text)
depositCash(COIN10P) = CInt(UIPence10.Text)
depositCash(COIN20P) = CInt(UIPence20.Text)
depositCash(COIN50P) = CInt(UIPence50.Text)
depositCash(COIN100P) = CInt(UIPound1.Text)
**depositCash(COIN200P) = CInt(UIPound2.Text)**
'Displays
SetCoinAmount("0")
depositAmount(depositCash)
DisplaySandingAmount()
'Curser Should Focus
UIPence1.Focus()
End Sub
答案 0 :(得分:0)
如果为整数分配字符串值,则必须在分配之前将该字符串转换为整数。如果字符串不包含数字,则会导致错误。您可以使用isnumeric或integer.tryparse函数使用if语句测试字符串,以确保在将字符串(文本框中的值)分配给整数(depositCash)之前它是合法的数字。