Posted on 1998-12-18
I have a couple of questions re debugging a program and finding errors:
First Some Background:
I often use Debug.Print statements throughout the program to help monitor the program flow pattern. This enables me to quickly narrow down on the code which causes the error.
I also use an Error Handler Function which traps program errors and displays:
Screen.ActiveControl.Name (if one exists)
Several Status Flags *
Approximate Line Number *
*Note: The Status Flags and Line Number displays are determined by various Flag and Line Number variables which are set at critical points throughout the program.
In the error handler I also use a vbYesNoCancel MsgBox to determine the disposition of the error. I can stop program execution immediately, or return to the Main Program Menu, or try to continue program execution from where the error occurred.
In the development environment, my Debug.Print statements, while extremely useful in tracing program flow, produce hundreds of lines in the Immediate Window. So each time I run the program I have to manually clear the Immediate Window (by Highlighting and Deleting all lines)
Is there a way to CLEAR THE IMMEDIATE WINDOW by some code at the beginning of the program so that it is always cleared when the program starts running?
Sometimes the error handler gets in the way of tracing the error because it clears the error before you can identify the exact place where the error occurred. If you go to "Tools - Options - General" in the development environment, you can click a button which enables a "Break on All Errors" option. However I cannot use this option because I have some DELIBERATE errors in my program which I use to trigger various choices. So my question is this: Can you turn the "Break on All Errors" option ON and OFF programatically at various critical points in the program. If so what is the code?