Add a watch expression to a Visual Basic project

You can add a watch expression, which is a user-defined expression that enables you to observe the behavior of a variable, a property, a function call, or any other valid expression. Watch expressions appear in the Watch window of the Visual Basic Editor and are automatically updated when you enter break mode. Watch expressions are not saved with your code.

  1. Select an expression, and then on the Debug menu, click Add Watch.

    Tip: You can drag a selected expression from the Code window into the Watch window.

  2. To set the scope of the variables watched in the expression, do any of the following:

To evaluate

Do this

A procedure

Under Context, on the Procedure pop-up menu, click the one that you want.

A module

Under Context, on the Module pop-up menu, click the one that you want.

  1. To determine how Visual Basic responds to the watch expression, do one of the following:


Do this

Update the values of the watch expression when you enter break mode

Under Watch Type, click Watch Expression.

Enter break mode when the expression evaluates to true or is any nonzero value

Under Watch Type, click Break When Value Is True.

Enter break mode when the value of expression changes within the specified context.

Under Watch Type, click Break When Value Changes.

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!