好的,所以我必须捕获介于1-24之间的int数字,任何高于此值的数据(24小时格式)都应该显示标准的messagebox.show错误消息。我试过声明如下:
Dim intNumber As Integer 如果intNumber> 24 show.MessageBox(“仅24小时格式”)`
它不起作用。我不确定以前的情况是否对我的声明有影响。这是我的代码。感谢您的帮助。
'This textbox requests input from user in form of numbers representing Hours of Operation Used and validates data'
Private Sub HoursOfOperation_TextChanged(sender As Object, e As EventArgs) Handles HoursOfOperation.TextChanged
Try
Convert.ToDouble(HoursOfOperation.Text)
Catch ex As Exception
MessageBox.Show("Please only type numbers!”)
HoursOfOperation.ClearUndo()
End Try
End Sub