tags:

views:

910

answers:

5

VB 6.0 does not have any global handler.To catch runtime errors,we need to add a handler in each method where we feel an error can occur.But, still some places might be left out.So,we end up getting runtime errors.Adding error handler in all the methods of an application,the only way?

+2  A: 

No there is no way to add a global error handler in VB6. However, you do not need to add an error handler in every method. You only really need to add an error handler in every event handler. E.g. Every click event,load event, etc

Darrel Miller
But, what about a normal method in a class,which may be doing some calculation,and throw an overflow error?
ravi
In a VB6 application, once you show a form, all interaction with that application has some event handler at the top of the call stack and as Brad Richards says, errors propagate upwards. The only non-event handler than needs a handler is Sub Main.
Darrel Miller
A: 

on error resume next - is kinda close but its been a while. you might want to look up any caveats

+1  A: 

Also: errors do propagate upwards: if method X calls methods Y and Z, a single error handler in method X will cover all three methods.

Brad Richards
A: 

While errors do propogate upwards, VB6 has no way to do a stack trace, so you never know which method raised the error. Unfortunately, if you need this information, you have to add a handler to each method just to log where you were.

Mike Dimmick
A: 

I discovered this tool yesterday:

http://www.everythingaccess.com/simplyvba-global-error-handler.htm

It is a commercial product that enables global error handling in VB6 and VBA applications.

It has its cost but does its job perfectly. I have seen other tools (free though) helping in this VB6 mangle, but none can cover a true real global error handling like "SimplyVB6 Global Error Handler for VB6" does.

With "SimplyVB6 Global Error Handler for VB6", there is no need to change any line of existing code, and no need to number the lines of code (via a plug-in or something). Just enable Global error handling (one line of code in the main module) and you are all set.

"SimplyVB6 Global Error Handler for VB6":

  • can show the call stack with real module and function names, as well as display the source code line.
  • Works only with P-Code compiled VB6 programs.
  • can work via early or late binding (no DLL Hell).

I am not in any way affiliated to www.everythingaccess.com, just happy to have found it yesterday afternoon, was kind of looking at this problem again as one of my customers was having bugs in our VB6 application. I was able to test the tool yesterday afternoon, exchanging emails with the www.everythingaccess.com support and getting the evaluation product per mail. Their web side does not allow yet to download the evaluation version of the VB6 product, you have to email them but they are answering in less than an hour.

Marc G.