|
-
Jun 20th, 2006, 05:21 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] Readout of ALL declared variables
Ok. I'm having trouble isolating some problems (mainly bugs) in a program I've written. What would be really helpful is some way to pause the program at some point and see all the stored values I have (ie for every single declared variable, display its value). Given the size of the program, it would be painful to write a function attached to a button to display all the information I want in a message, so I'd love to hear at this point that there is a simple way to do what I need 
Failing that, I guess I'll just write the function and only implement the ones I need to see as I go...
-
Jun 20th, 2006, 06:45 PM
#2
Re: [2005] Readout of ALL declared variables
You should be using the Locals and Watch windows while debugging to trace variable and propery values. You can also evaluate any expression in the Watch window and you can use the Immediate window to evaluate expressions and even assign new values to variables and properties while your app is running. I suggest reading some documentation on using the VS 2005 debugger.
-
Jun 20th, 2006, 07:28 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] Readout of ALL declared variables
I've skimmed a number of articles in the MSDN Library, and still cannot get watching happening. I've tried to set a watch up on a global variable named NoOfSpans which has a value at definition and is changed later, but I get the error "Unable to evaluate expression". This is regardless of whether the program is running or paused.
I'm sure I'm making a simple mistake somewhere, but I'm not sure where. Any suggestions?
-
Jun 20th, 2006, 10:23 PM
#4
Re: [2005] Readout of ALL declared variables
The way I do it is to put a breakpoint somewhere where the variable is in scope. Then select the variable, and press Shift+F9. That gives you the current value, and a button like Add Watch. Press it.
However, I rarely end up adding watches, and you may find that using breakpoints and Shift+F9 is sufficient for your needs without dealing with watch variables.
My usual boring signature: Nothing
 
-
Jun 20th, 2006, 10:49 PM
#5
Thread Starter
Hyperactive Member
Re: [2005] Readout of ALL declared variables
Thats really odd. I couldnt get the variables to show properly in the watch, but after I added the breakpoint and a variable within the function, not only that variable worked, but also all the other variables I'd tried to watch earlier. Until now I've been using msgbox to get the info I need, so this should make it a lot quicker. Thank you for your help
-
Jun 20th, 2006, 10:56 PM
#6
Re: [RESOLVED] [2005] Readout of ALL declared variables
You can't Watch a variable while your app is executing. You have to use a breakpoint so that the debugger can evaluate it. If the app is executing its value may be changing repeatedly. You can only get its value at specific points, not continuously. If you want to get a variable's value while the app is executing then you'd have to write a series of Debug.WriteLine or Trace.WriteLine instructions to write that values to the Immediate window.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|