Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Readout of ALL declared variables

  1. #1

    Thread Starter
    Hyperactive Member ZaNi's Avatar
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    360

    Resolved [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...

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member ZaNi's Avatar
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    360

    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?

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    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

  5. #5

    Thread Starter
    Hyperactive Member ZaNi's Avatar
    Join Date
    Jun 2006
    Location
    Australia
    Posts
    360

    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

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width