現在、MS Access VBA で InputBoxes を使用しています。ユーザーが [OK] または [キャンセル] ボタンを押して 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 が実際に文字列を返すという問題はありますか?