February 23rd, 2000, 02:25 PM
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
|
Click to See Complete Forum and Search --> : on error goto whatever February 23rd, 2000, 02:25 PM 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 Kyle Burns February 23rd, 2000, 02:46 PM 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 Rippin February 23rd, 2000, 02:52 PM 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |