I want to log the exceptions occurred during execution of my app. Before this I handled it with message box. I am new to VB 6.
Please provide some sample code to create log file and to save exception messages.
Thanks..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need error handlers, using
On Error Goto, so that you can execute your own code when an error occurs. (BTW in VB6 they are called errors not exceptions.) The free tool MZTools is excellent – it can automatically insert theOn Error Gotoand an error handler which includes the name of the current routine.You also need a general routine that logs error details to a file, a little bit like this below. Health warning – I’ve just typed this straight in without testing it (air code).
Bonus suggestion: roll your own stack trace.
Bonus suggestion 2: switch off the error handlers in the IDE with something like this
If Not IsInIDE() Then On Error Goto Handler, using theIsInIDEfunction from here