How to: Edit a Value in a Variable Window
The variable windows, Autos, Locals, and Watch, display the values of certain variables during a debugging session. The QuickWatch dialog box can also display variables. When the debugger is in break mode, you can use the variable windows to edit the values of (most) variables that appear in these locations.
Editing floating-point values can result in minor inaccuracies because of decimal-to-binary conversion of fractional components. Even a seemingly harmless edit can result in changes to some of the least significant bits in the floating-point variable.
When an expression is evaluated in this window, you might see a refresh icon. This indicates an error or out-of-date value. For more information, see.
If you like, you can enter an expression for a value. The debugger will evaluate the expression and replace it with the resulting value. The debugger accepts most legal language expressions in a Watch window. For more information, see.
If you are programming in native code, you may sometimes need to qualify the context of a variable name or an expression containing a variable name. The context means the function, source file, and module where a variable is located. If you need to do this, you can use the context operator syntax. For more information, see.)
Evaluating some expressions can change the value of a variable or otherwise affect the state of your program. For example, evaluating the following expression changes the value of var1 and var2:
var1 = var2++
Expressions that change data are said to have side effects, which can produce unexpected results if you are not aware of them, so be sure you understand the effect of an expression before you execute it.
To edit a value in a variable window or in QuickWatch
The debugger must be in break mode.
If the variable is an array or object, a tree control appears next to the name in the Name box. In the Name column, expand or collapse the variable to find the element whose value you want to edit.
In the row you want to change, double-click the Value column.
Type the new value.