Question

If a run-time error occur in a VB6 app, does this mean Error handling has been turned off by use of the On Error Goto 0 statement?

Can this assumption be made? Or are there other circumstances in which a run-time error could occur?

If an error has been handled by either a Resume Next or a Goto then surely a run-time error would not occur. True or False?

Was it helpful?

Solution

It occurs because there is no error handler within the executing code, including calling procedures. You cannot make the assumption that On Error Goto 0 was used.

I am assuming you mean an unhandled run-time error. Since it is unhandled, your application "ends abnormally".

Visual Basic Concepts, Error Handling Hierarchy, http://msdn.microsoft.com/en-us/library/aa241677(VS.60).aspx

If an error has been handled by either a Resume Next or a Goto then surely a run-time error would not occur. True or False?

False. Sometimes a run-time error will occur in the error handler. If your error handling logic misses this, you will get an unhandled run-time error.


More Information

Briefly, using On Error Goto 0 removes any error handler (disables or turns off) within the procedure until the procedure ends or you assign an error handler using one of the On Error statements. User-Interface events with no error handling code will also have no error handler until you define one.

Error Trapping

During debugging, you can specify "Error Trapping" which causes VBE to break "on-all-errors", "in-class-module", or "on-unhandled-errors". During run-time, the behavior is "On Unhandled Errors" (A run-time error will occure if the Visual Basic Run-Time Library can find no error handler.). If you are troubleshooting / debugging, try setting "Error Trapping" to "Break on All Errors". This will cause VBE to break at the point of the error, where you can start debugging or just contine execution.

OTHER TIPS

If you are trying to sort out a problem, I recommend using a debugger to reproduce the error message, and then pause code execution and see where the error occurs. Check the call stack, look at variable values, and figure out how the error is happening.

  • Use the VB6 IDE if possible.
  • If the problem does not occur when using the VB6 IDE use another debugger, for instance Visual Studio 2008 Express Edition which is free.

There are several situations in which an error could occur. For example you could execute a code line that triggers an event to fire and be handled immediately, and the event handler might experience an error (if the event handler does not have error handling). Also sometimes VB6 runtime errors can be displayed when your app starts, before any of your code is executed.

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