【发布时间】:2013-04-10 07:19:34
【问题描述】:
我目前正在使用 MS Access VBA 中的 InputBox。我正在检查验证并处理用户如何通过按下 OK 或 Cancel 按钮与 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 实际上是返回一个字符串的问题吗?
【问题讨论】:
标签: ms-access vba ms-access-2007