Dim strResult as String
Dim intResult As Integer
Dim lngErr as Long
Do
strResult = InputBox ("Enter an integer here"
On Error resume next
intResult = Cint(strResult)
lngErr = Err.Number
On error goto 0
if lngErr = 0 then
* User could enter "-1"
if intResult >= 0 then exit do
End if
Loop
'Try this
Function AskForNum() As Integer
Dim ans%
On Error Resume Next
AskForNum = 42 'default value
AskForNum = InputBox("Enter an integer here"
'if entry was invalid default is returned
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.