VB InputBox

来源:百度知道 编辑:UC知道 时间:2024/06/21 09:31:37
用INPUTBOX
输入数字用,但怕别人输入字母或不输入会出错,怎么解决?
取消好象也不能按~~

Sub Test()
Begin:
A=InputBox("输入数字")
If IsNumeric(A)=False Then Msgbox "请输入数字" , vbCritical , "错误!" : Goto Begin
End Sub

给你个示例:
Private Sub Command1_Click()
Dim A As Long
Do
s = InputBox("请输入一个数字")
Loop While IsNumeric(s) = False
A = Val(s)
End Sub