方法一: 不推荐. Private Sub Command1_Click() Dim n As Integer On Error GoTo errHandle
n = InputBox("input datas") MsgBox n Exit Sub
errHandle: MsgBox "输入出错" End Sub
方法二: Private Sub Command1_Click() Dim s As String Dim n As Integer s = InputBox("input datas") If IsNumeric(s) Then n = s MsgBox n Else MsgBox "输入出错" End If End Sub