Add a watch expression to the Watch window of the Visual Basic Editor

Add a watch expression to the Watch window of the Visual Basic Editor

  1. Open a procedure in the Code window.

  2. On the Debug menu, click Add Watch.

  3. If you already selected an expression in the Code window, it is automatically displayed in the dialog box. If no expression is displayed, type the expression you want to evaluate. The expression can be a variable, a property, a function call, or any other valid expression.

    Instead of typing the expression, you can also select an expression in the Code window and drag it to the Watch window.

  4. To select the range for which the expression will be evaluated, select a module and procedure context under Context.

    Note   Select the narrowest scope that fits your needs. Selecting all procedures or all modules could slow down code execution.

  5. To define how the system responds to the watch expression, select an option under Watch Type.

When you run the code, the Watch window shows the value of the expression you set. To modify a watch expression, select the expression in the Watch window, and then click Edit Watch on the Debug menu. To delete the watch expression, click Delete in the Edit Watch dialog box.