Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Handling Example

VB Programming Concepts

Error Handling Example

by  jlgdeveloper  Posted    (Edited  )
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.

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

Notes:
======
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.

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

exit sub '*** could be a function
errorhandler:
App.LogEvent vbCrLf & Err.Description & vbCrLf _
& Err.Number & vbCrLf & App.EXEName & " your sub name here"
'***here use any of the following
err.clear
resume next
'*** or your bail out code
End Sub
===========================
Jonathan Galpin MCSD +++¼
www.iqzero.net
because software should be easy to use
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top