MHz Posted October 19, 2004 Posted October 19, 2004 $answer = InputBox('Input', 'Enter data') MsgBox(0, 'Data', $answer) If @error = 0 Then MsgBox(0, '', 'The string returned is valid') ElseIf @error = 1 Then MsgBox(0, '', 'The Cancel button was pushed') ElseIf @error = 2 Then MsgBox(0, '', 'The Timeout time was reached') ElseIf @error = 3 Then MsgBox(0, '', 'The InputBox failed to open') Else MsgBox(0, '', 'I do not now') EndIf If I press cancel on the InputBox, I receive @error = 0. Should be @error = 1 ? Am I checking the error status incorrectly ?
Valik Posted October 19, 2004 Posted October 19, 2004 @error is reset after every function call. You call MsgBox() between the InputBox() call and the time you start checking @error.
MHz Posted October 19, 2004 Author Posted October 19, 2004 Dim $answer, $err $answer = InputBox('Input', 'Enter data') $err = @error If $err = 0 then MsgBox(0, '', 'The string returned is valid') If $err = 1 then MsgBox(0, '', 'The Cancel button was pushed') This example produces a difference. Would below be the best non-knuckleheadish method for cancel button pressed? Dim $answer, $err $answer = InputBox('Input', 'Enter data') $err = @error If $err = 1 then Exit
MHz Posted October 19, 2004 Author Posted October 19, 2004 $answer = InputBox('Input', 'Enter data') If @error = 0 Then MsgBox(0, '', 'The string returned is valid') If @error = 1 Then MsgBox(0, '', 'The Cancel button was pushed') If @error = 2 Then MsgBox(0, '', 'The Timeout time was reached') If @error = 3 Then MsgBox(0, '', 'The InputBox failed to open') Tried this first up but was getting @error = 0 everytime, now is working. I must have created my own error somewhere in the code? Changed so many times lost track of how I achieved it. My understanding is back on course. Thanks Valik. Thanks Larry.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now