My code
Dim a As Integer
a = InputBox("Enter the number", "Program", "", 7000, 6000)
If a = Empty Then
' do code...
Else
MsgBox "Enter the number."
End If
如果我留空字段,Excel 将返回Type Mismatch
错误。我想显示一条消息。
Since a
is an Integer
,它不能包含String
or be Empty
. Use a Variant
然后检查返回的内容:
Dim a As Variant
Dim b As Integer
a = InputBox("Enter the number", "Program", "", 7000, 6000)
If Not IsNumeric(a) Then
'a is not a number
Else
'a is a number and can be converted to Integer
b = CInt(a)
End If
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)