Share via


Viewing the Value of a Variable or Contents of a Register

Home Page (Debugger)OverviewHow Do I... Topics

What do you want to do?

View the value of a variable or expression or the contents of a register

View the value of a variable using QuickWatch

View a the value of a variable or expression or the contents of a register in the Watch window

View type information for a variable in the Watch window

View a variable in the Variables window

View type information for a variable in the Variables window

Display meaningful values for your custom data type?

To view the value of a variable or expression or contents of a register

  1. Wait for the debugger to stop at a breakpoint.

    – or –

    Click Break on the Debug menu to halt the debugger.

  2. On the Debug menu, click QuickWatch.

  3. Type or paste the variable or register name or an expression into the Expression text box, and click Recalculate.

  4. Click Close.

Tip   The Expression drop-down list box contains the most recently used QuickWatch expressions.

To view the value of a variable using QuickWatch

  1. When the debugger is stopped at a breakpoint, switch to a source window, and click the right mouse button on a variable (Var, for example).

  2. On the shortcut menu, click QuickWatchVar.

  3. Click Close.

To view the value of a variable or expression or the contents of a register in the Watch window

  1. Start debugging, and pause the debugger in break mode (program is waiting for user input after completing a debugging command).

  2. On the View menu, click Debug Windows, then click Watch.

  3. Select a tab for the variable or expression.

  4. Type, paste, or drag the variable or register name or an expression into the Name column on the tab.

    Press ENTER (if typing).

    The Watch window evaluates the variable or expression immediately and displays the value or an error message.

If you add an array or object variable to the Watch window, plus sign (+) or minus sign (–) boxes appear in the Name column. Use these boxes to expand or collapse your view of the variable described in Spreadsheet Fields.

Change the Watch window display format (to display Unicode characters, for example) using formatting symbols, described in Symbols for Watch Variables.

To view type information for a variable in the Watch window

  1. In the Watch window, select the line containing the variable whose type you want to see.

  2. On the View menu, click Properties.

To view a variable in the Variables window

  1. Start debugging, and pause the debugger in break mode (program is waiting for user input after completing a debugging command).

  2. On the View menu, click Debug Windows, then click Variables.

  3. Click the Auto tab, Locals tab, or This tab, according to the type of variables you want to see.

To view type information for a variable in the Variables window

  1. In the Variables window, click the Auto tab, Locals tab, or This tab.

  2. Select the line containing the variable whose type you want to see.

    On the View menu, click Properties.

To display meaningful values for a custom datatype

The file autoexp.dat controls how the debugger displays data types in windows, Quickwatch, and DataTips. You can modify this file to add meaningful displays for your own datatypes. For details, see the autoexp.dat file itself (located in the /bin directory).