The Watch Window

Besides the Immediate window, another useful tool for debugging VBA programs is the Watch window. The Watch window makes it possible to track the value of a variable or expression (property, function call, and so on) from anywhere in a program. Add a watch to an expression from the Debug menu or right click the expression and choose Add Watch from the shortcut menu. The resulting dialog box is shown in Figure 7.7.

The Immediate window.

The Immediate window.

The Add Watch dialog box.

The Add Watch dialog box.

Choose either a specific procedure containing the expression you want to watch, or choose all procedures. Next, choose a specific module containing the expression you want to watch, or select all modules. Finally, select the type of Watch (Watch Expression, Break When Value Is True, or Break When Value Changes). The watch type selected will be displayed in the Watch window only when the program enters Break Mode. Therefore, if the Watch type Watch Expression is selected, a breakpoint will have to be inserted in the procedure(s) containing the expression before running the program. The other two watch types automatically pause the program at the specified location. A Watch window showing the value of an expression while the program is in Break Mode is shown in Figure 7.8.

The Watch window.

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment