Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » General

Post new topic   Reply to topic
On Error GoTo ----
View previous topic :: View next topic  
Author Message
robertlees
Newbie


Joined: 19 Sep 2005
Posts: 22
Location: Sydney, Australia

PostPosted: May 10th, 2006 04:13 AM    Post subject: On Error GoTo ---- Reply with quote

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
View user's profile Send private message
i_am_doofus
Regular


Joined: 04 Jun 2005
Posts: 57

PostPosted: May 10th, 2006 07:38 AM    Post subject: Reply with quote

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
View user's profile Send private message
robertlees
Newbie


Joined: 19 Sep 2005
Posts: 22
Location: Sydney, Australia

PostPosted: May 10th, 2006 05:32 PM    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic