|
-
February 23rd, 2000, 03:25 PM
#1
on error goto whatever
how come when i put on erro goto error, then under the error: i put msgbox "error" to test things out, why does it message box me "error" even though theres been no error
-
February 23rd, 2000, 03:46 PM
#2
Re: on error goto whatever
My guess is that you don't have Exit Sub before your error handler. Does your code look like this?
public Sub Foo()
on error GoTo error 'I wouldn't use a keyword for a label. How about "on error Goto Handler"?
'Do some stuff that may cause an error
ExtProc:
Exit Sub
error:
MsgBox "error"
resume ExtProc
End Sub
-
February 23rd, 2000, 03:52 PM
#3
Re: on error goto whatever
I'm not sure I understand your problem EXACTLY, but if I am right you have some code like this:
public Sub MySub()
'
on error Goto MyError
'
'Some code here...
'
MyError:
MsgBox "error"
End Sub
And everytime you run the code, you still get the messagebox telling you that an error has occurred. Am I right? If I am, the solution is to add an Exit Sub right before the MyError (or whatever yours is named) label. For example, try this:
public Sub MySub()
'
on error GoTo MyError
'
'Some code here...
'
Exit Sub
'
MyError:
MsgBox "error"
End Sub
Hope this helps,
Rippin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|