3

When I'm debugging my application something is not right, and I can't continue. So is it possible to see the output code of my app while I'm testing it to see what is wrong?

I open the output window but nothing happens in there it's just stay blank. In two words: I want to see what my app is actually doing while I'm testing it. I'm using Visual Studio 2010.

1
  • VBA isn't VB.Net, so you should fix your question tags to get help from the right people. You might also tell us what you mean by "output code." I searched for "debugging vb.net 2010" and found this, which should be helpful: codeproject.com/Articles/79508/…. Commented Mar 19, 2013 at 2:23

1 Answer 1

14

So is it possible to see the output code of my app while im testing it to see what is wrong?

Yes, but you actually have to output something, otherwise nothing will show up. In VB.NET (which is the language you're using if you have Visual Studio 2010), this is accomplished with the following code:

Debug.Print("Here is some text that will be output.")

The documentation for the Debug.Print method is here. In order to call it like that, you will also have to have imported the System.Diagnostics namespace. You do so by placing the following line at the top of your code file (with all the other statements that look like it):

Imports System.Diagnostics

The output will automatically appear in the Output Window. If you still don't see anything, ensure that output is not being redirected to the Immediate Window instead: Tools -> Options -> Debugging -> General -> uncheck the option "Redirect all Output Window text to the Immediate Window".


Confusingly, you use the word "code" in your question, saying that you wish to "see the output code of [your] app while testing it". I'm not sure if by "code" you actually mean "output", in which case the solution above will work for you.

If you actually mean code, as in your program's source code, then you can use the Break toolbar button (or press Ctrl+Break) in the IDE to pause the execution of your program. This will automatically dump you back into the code editor with the currently-executing line of code highlighted.

Visual Studio has some very powerful debugging tools. If you don't already have a general idea of how to use them, I strongly recommend picking up a book on either it or VB 2010 that will teach these things to you. They can be very confusing to learn by trial and error, but are not all that difficult if you have a good guide. Spend that time debugging your code, not figuring out how to use the IDE.

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you for the quick reply. Yes i actually mean code ( source code ). Ctrl + Break is very close to that I want, but when dump me back it's says "No source available" . I have idea why is says that , because i press button and from this action i'm expecting two reactions. but only one of them appears. And maybe this Ctrl + Break is not valid on that kind of action (button) , beacause probably the compiler think "the action is done" and therefore "No source available" That's what i think. Thank you very much, it was good explained and very literate wrote. Very helpful thank you again. :))
Set a breakpoint where you want to pause execution. This will let your code run normally until it hits the breakpoint, then it will pause there. When the code is paused you can see the value of variables, edit the value of variables, step through line by line, terminate the execution, or continue normally. You can set a breakpoint by clicking to the left of the line of code
Its works in VS2010E, VS2010P, VS2015CE, soon i will check in VS2013P, but i think that would be ok :D thx for the answer :)
For anyone who just can't a message to show on the output window even though everything is working : don't forget to put your project on debug mode, not release mode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.