vb编程中 如何使输入 input的数满足一定条件

来源:百度知道 编辑:UC知道 时间:2024/05/21 11:27:47
比如说 让输入数N 在0~10之间,在范围之外就需重新输入

哈哈,再改造一下二楼的:
Private Sub Command1_Click()
Dim a as integer ,st as string
Do
st = InputBox("input number between 0 and 10")
if not IsNumeric(st) then exit sub
a = val(st)
if a <0 or a>10 then exit sub
Loop
MsgBox "the number is : " & a
End Sub
我编程时常用这种方法

Private Sub Command1_Click()
Dim a
Do
a = InputBox("input number between 0 an 10")
Loop Until (a > 0 And a < 10)
MsgBox "the number is : " & a
End Sub

Private Sub Command1_Click()
Dim a as integer
Do
a = val(InputBox("input number between 0 an 10"))
Loop Until (a > 0 And a < 10)
MsgBox "the number is : " & a
End Sub

'//呵呵,改造了一下楼上的.