views:

120

answers:

6

Hello,

I want to know if there is any way I can change the value of a variable during execution time, using Visual Studio 2008? I know I can do this on Eclipse (put a breakpoint, add a watcher and edit whatever variable value I want) but I didn't find this feature on VS yet?

Any idea?

Thanks

+2  A: 

Use the Immediate Window.

Leniel Macaferi
+5  A: 

In VS, there is the command/immediate window (when debugging, under the Debug -> Windows menu) which allows you to change variable values.

A more visual way is the Variable window.

Oded
+5  A: 

Hi,

In VS if you hover your mouse over this variable, you'll notice it displays it's value in a tooltip. You can click into this tooltip and edit it manually - though you need to provide a value of the correct format for the data type. Strings also need quotes "".

There is likely a way to do this via some of the other debugging windows, but I don't know of any. I'll leave those answers to someone else.

Adam

Adam
That's right :)
Amokrane
+2  A: 

Yes. There are several Ways.

Double-click the variables value in the Watch, Local or Auto's window. You can also do this from the immediate window.

Mitch Wheat
+1  A: 

You can do this as follows: 1. Put a breakpoint just after the line of code where you want to update the varaible value. 2. Run the application till the breakpoint is hit. 3. Just hover over the variable you want to edit and the varable name and value will be shown. 4. Click on the Value field and edit it, press enter.

Mission accomplished...

Chinjoo
A: 

You can do it using one of the following ways

  • User Immediate window
  • Using quickwatch window

Both allow user to change the variables value.

Ram