Is there a way to add global error handler in a visual basic 6.0 application?

StackOverflow https://stackoverflow.com/questions/65020

  •  09-06-2019
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

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.

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top