Using Quick Watch

If you want to check the value of an expression for which you have not defined a watch expression, you can use Quick Watch (Figure 13-11).

Figure 13-11:

The Quick Watch dialog box shows the value of the selected expression in a VBA procedure.

The Quick Watch dialog box can be accessed in the following way:

■ While in break mode, position the insertion point anywhere inside the name of a variable or expression you wish to watch.

■ Choose Debug | Quick Watch, or press Shift+F9.

gras xi

Debugging, Breaks. WhatDate

r •

newDate

Add

Cancel

2002-02-04

Help

The Quick Watch dialog box shows the value of the selected expression in a VBA procedure.

The Quick Watch dialog box contains the Add button that allows you to add the expression to the Watches window.

Make sure the WhatDate procedure does not contain any watch expressions. See the preceding section on how to remove a watch expression from the Watches window. Now, let's see by example how to take advantage of the Quick Watch.

1. In the WhatDate procedure, position the insertion point on the name of the variable x.

2. Choose Debug | Add Watch.

3. Enter the following expression: x = 50.

4. Choose the Break When Value is True option button, and click OK.

5. Run the WhatDate procedure.

Visual Basic will suspend procedure execution when x equals 50. Notice that the Watches window does not contain the newDate nor the curDate variable. To check the values of these variables, you can position the mouse pointer over the appropriate variable name in the Code window, or you can invoke the Quick Watch window.

6. In the Code window, position the mouse inside the newDate variable and press Shift+F9. The Quick Watch window shows the name of the expression and its current value.

7. Click Cancel to return to the Code window.

8. In the Code window, position the mouse inside the curDate variable and press Shift+F9. The Quick Watch window now shows the value of the variable curDate.

9. Click Cancel to return to the Code window.

10. Press F5 to continue running the procedure.

0 0

Post a comment