Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Visual Basic (Classic) FAQ

VB Programming Concepts

Error Handling Example by jlgdeveloper
Posted: 24 Aug 03

Please read the faq "Error Handling" by CasperTFG first, this is only meant as an additional note:

I use the "app.logEvent" call for the most part when handling errors. This writes a log to the application event viewer in the control panel.

App.LogEvent vbCrLf & Err.Description & vbCrLf _
     & Err.Number & vbCrLf & App.EXEName & " your sub name"

err.Description = the vb error description
err.Number = the error number
app.exename = the name of my program
vbCrlf = carraige return & line feed, to give me a new line
You can also add a number ie 1,2,3 to the call to indicate the severity of the error in the event viewer.

Sub nameOFSUB '*** could be a function
    on error goto errorhandler
    '*** code of the sub

    exit sub '*** could be a function
    App.LogEvent vbCrLf & Err.Description & vbCrLf _
     & Err.Number & vbCrLf & App.EXEName & " your sub name here"    
     '***here use any of the following
     resume next
     '*** or your bail out code
End Sub
Jonathan Galpin MCSD +++ΒΌ
because software should be easy to use

Back to Visual Basic (Classic) FAQ Index
Back to Visual Basic (Classic) Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close