Examining the Values of Variables During Execution

You can also display the values of selected variables as the code is executed. There are several ways to select variables or expressions to be displayed:

• Highlight the variable or expression and then choose Quick Watch...

from the Debug menu or press the Quick Watch button "1 on the Debug toolbar, to display the Quick Watch dialog box (Figure 2-26).

• Highlight the variable or expression and then choose Add Watch... from the Debug menu to display the Add Watch dialog box (Figure 227).

LINEST2.xls. Module 1 .MySLOPE

LINEST2.xls. Module 1 .MySLOPE

Expression

Value

<Out of context>

Figure 2-26. The VBA Quick Watch dialog box.

Add Watch

Expression;

Context Procedure:

Modute

Project:

Watch Type f Watch Expression

C Break When Value Is Jrue

( Break When Value Changes

Cancel

Cancel

¡MySLOPE

"3

Help

j Modulel

zl

LINEST2.xls

Watch Type f Watch Expression

C Break When Value Is Jrue

( Break When Value Changes

Figure 2-27. The VBA Add Watch dialog box.

To see the values of the selected variables or expressions, you must be in Step mode. The variables will be listed in the Watches pane (Figure 2-28), which is usually located below the Code window. The current values of the variables will be displayed as you step through the code.

Expression

2338.138

299.307

8507.926157

Type_

Variant ¿Double Va riant ¿Double Variant/Double Variant ¿Double Variant .Double

Context_

Modulel .MySLOPE Modulel .MySLOPE Modulel .MySLOPE Modulel .MySLOPE Modulel .MySLOPE

Variant/Long Modulel .MySLOPE

Figure 2-28. The VBA Watches pane.

To remove a variable or expression from the Watches window, select it in the Watches window, choose Edit Watch from the Debug menu and press the Delete button. Or you can simply select it in the Watches window and press the Delete key.

Watch expressions are not saved with your code.

This Page Intentionally Left Blank

Was this article helpful?

0 0

Post a comment