Adding a Watch Expression

You can add a watch expression before running a procedure or after entering break mode. You use the Add Watch dialog box to add watch expressions.

In the Expression box, enter the expression you want the watch expression to evaluate. The expression can be a variable, a property, a function call, or any other valid expression.

Under Context, click items in the list boxes to set the scope of the variables you want watched in the expression. Use these options if you have variables of the same name with different scope. You can also use these options to restrict the scope of watch variables. Visual Basic can evaluate a variable in a narrow context more quickly.

Under Watch Type, click an option button to set how you want Visual Basic to respond to the watch expression. Visual Basic can watch the expression and display its value in the Watch pane when the code enters break mode. Or you can have the code enter break mode automatically when the expression evaluates to True or when the value of the expression changes.

To add a watch expression

1. On the Tools menu, click Add Watch.

2. In the Expression box, type the expression you want to evaluate.

3. To set the scope of the expression to be watched, click the procedure or module name in the appropriate box under Context.

4. To determine how you want Visual Basic to respond to the watch expression, click an option button under Watch Type.