Using the Watch Window

The Watch Window can be used to see a list of objects and variables in the current procedure. The Watch Window can be used to monitor the value of variables as breakpoints are encountered, just as the Immediate and Locals Windows can. The Watch Window also provides additional features, such as allowing you to add a Watch that will cause the code execution to break when a certain event or value occurs. This enables you to have the system break for you automatically when the certain event occurs without having to set a predetermined breakpoint.

Try It Out Adding a Watch

Let's look at an example of adding a watch using the Watch Window.

1. From the Debug menu in the Visual Basic Editor, choose Add Watch.

Microsoft Visual Basic - Ch2CodeExamples - [modBusinessLogic (Code)]

iiS Fiäe Edit View insert i IHM- fei I ffi I "

Project - ChZtodeExamples

Et® acwztoo! (ACWZTOOL) Ä fe jgt Cbîtode Exam pies [Ch2Cod

S ■ ö Microsoft Office Access Cla* ■m Form frmTest

Properties - modBusinessLogic modBusinessLog Module Alphabetic I Categorized

¡Name: modBusinessLogic

Debug Hun Tools Add-ins Window Help

Compile Ch2CodeExamples

Compile Ch2CodeExamples

Et® acwztoo! (ACWZTOOL) Ä fe jgt Cbîtode Exam pies [Ch2Cod

S ■ ö Microsoft Office Access Cla* ■m Form frmTest

J

Step Into

F3

Step Over

Shift+FB

Step Out

Ctrl+Shift+F8

Run To Cursor

CtrUFS

Add Watch...

Edit Watch...

Ctrl+W

Quick Watch...

Shift+F9

a

Toggle Breakpoint

F9

Clear All Breakpoints

Ctrl+Shift+F9

Ctrl+F9

Set Next Statement Show Next Statement

Ctrl+F9

Figure 2.37

2. On the Add Watch dialog box, specify intCounter as the Expression, TestLoop as the procedure, and modBusinessLogic as the Module.

3. Click the OK button on the Add Watch dialog box, and a Watches Window will appear.

4. Run the TestLoop procedure again from the Immediate Window. You should see the values in the Watches window change when the first breakpoint is encountered.

0 0

Post a comment