Microsoft Office Tutorials and References
In Depth Information
Weapons of Mass Debugging
Select the expression you want to watch, right-click that selection, and choose Add Watch from the
pop-up menu. Figure 17-15 shows the process for adding the variable strValue to the Watch list.
The Add Watch dialog box will appear, as shown by example in Figure 17-16, for you to confirm
your settings and click OK.
When you step into code after setting a watch expression,
you’ll see the expression’s value change during
execution. Figure 17-17 shows the strValue variable’s value
change with each iteration of the For Next loop. Notice
that the value at one point in the loop is a number, yet
the strValue variable was declared as a String type.
It’s that kind of attention that the Watch window brings
to your awareness of what your variables are actually
returning, if you suspect a particular expression to be
the cause of an error.
The Quick Watch window allows you to
get a look at the current value of an
expression or variable for which you have not
defined a watch expression. While you are
in Break mode, select your expression in the
module and click the Quick Watch button,
or press the Shift+F9 keys. For example, in
Figure 17-18, the intCounter variable was
selected during a step through process, and
the Watch window displays 3 in the Value
field, indicating that the For Next loop is
currently in its third iteration.