| View previous topic :: View next topic |
| Author |
Message |
robertlees Newbie
Joined: 19 Sep 2005 Posts: 22 Location: Sydney, Australia
|
Posted: May 10th, 2006 04:13 AM Post subject: On Error GoTo ---- |
|
|
How does error handling work ? Please tell me where I am going wrong
At the start of my app I say On Error GoTo MyErrorHandler
In a module, making it global, enter
MyErrorHandler:
msgbox err.description
end
Then if any error (for example divide by zero) happens anywhere in the project, control will jump to the above MyErrorHandler.
What do you think ?
Thanks |
|
| Back to top |
|
i_am_doofus Regular
Joined: 04 Jun 2005 Posts: 57
|
Posted: May 10th, 2006 07:38 AM Post subject: |
|
|
Not sure that you can have a global error handler per se.
You need to include the "On Error GoTo MyErrorHandler" AND the "MyErrorHandler:" notations in every Sub and Function you want covered. In addition, you'll need to include the body of the error handler in all these places too.
What you might try, is to create a Sub in a module like this:
Public Sub my_error_handler(err As ErrObject)
msgbox err.description
End Sub
And then make a call to that sub in the error handler of each sub/function in your project like this:
MyErrorHandler:
Call my_error_handler(err)
Haven't tested it, so I'm not sure it would work. Worth a shot however. |
|
| Back to top |
|
robertlees Newbie
Joined: 19 Sep 2005 Posts: 22 Location: Sydney, Australia
|
Posted: May 10th, 2006 05:32 PM Post subject: |
|
|
| Thanks for your reply. It confirmed for me the way I thought I would go. I've now made an app that makes a new version of all the files in the app, placing On Error and error handler at front and back of every sub and function. They each go to the same routine in a module. My next tast is to detect all frm and bas files in the folder. I guess though I should examine the vbp file. Maybe I'll do that. |
|
| Back to top |
|
|