我目前正在使用MS Access VBA中的InputBoxes。我正在检查验证并处理用户如何通过按下“确定”或“取消”按钮与InputBox交互。输入框问题
纠正我,如果我错了,但InputBoxes可以返回任何数据类型,默认返回一个字符串?例如:
Dim userInputValue As String
'Text to display, Title, Default Value
userInputValue = InputBox("Please enter a #", "Determine Limit", 10000)
If userInputValue = "" Then
MsgBox ("You pressed the cancel button...")
End If
如果用户按下“取消”按钮,它将正常运行。
但是,当我换这一个整数值,像这样:
Dim userInputValue As Integer
'Text to display, Title, Default Value
userInputValue = InputBox("Please enter a #", "Determine Limit", 10000)
If userInputValue = 0 Then
MsgBox ("You pressed the cancel button...")
End If
我收到Type Mismatch: Runtime Error '13'
这是为什么?当我调试代码并查看返回的内容时,我发现userInputValue
实际上是0,这正是我正在检查的内容。那么InputBox实际上返回一个字符串的问题呢?
这是确定汉斯:) –