我有這個代碼似乎工作得很好。唯一的問題是,如果我在文本框中,然後雙擊該按鈕或雙擊回車鍵我來到這裏的例外如何創建一個數組並放入列表框
「如果GotxtBox.Text < 10然後」
提示「無效的情況下,異常未被擴大「 」從字符串到double類型的轉換無效「我如何阻止這種情況發生?
Private Sub GoBtn_Click(sender As Object, e As EventArgs) Handles GoBtn.Click
If GotxtBox.Text < 10 Then
MessageBox.Show("Number can not be less than 10")
GotxtBox.Clear()
Return
End If
If GotxtBox.Text > 100 Then
MessageBox.Show("Number can not be greater than 100")
GotxtBox.Clear()
Return
End If
Dim number As Integer = Val(GotxtBox.Text) ' get number
' add the number to the end of the numberListBox
GoLstBox.Items.Add(number)
If GoLstBox.Items.Count = 20 Then
GoBtn.Enabled = False
MessageBox.Show("Exactly Twenty Numbers Must Be Entered")
End If
GotxtBox.Clear()
GotxtBox.Focus()
End Sub
您的標題似乎不符合問題。 – LarsTech