The .NET Developer Community

How to use Debug.Print in VB.Net

rated by 0 users
This post has 5 Replies | 0 Followers

itmasterw
Top 500 Contributor
Amherst, NY
Since 4/23/2003
Posts 288
Reputation 5,025
Edward Walsh (itmasterw) Posted: 12/4/2008 10:27 AM
Hi,
In VB6 I would use Debug.Print to view the values in a variable in the Immediate window. But now I do not see that. Some one tolled me it is in the OutPut window but I do not get anything there either.
This is an example of how I am using it.
a = "Test555"
        Debug.Print(a)
Any ideas would be appreciated.
Thank you
  • | Post Points: 50
XTab
Top 10 Contributor
Scotland
Since 2/21/2002
Posts 10,984
Reputation 118,563
ForumsAdministrator
vbCity Team
Console.Writeline is your .NET friend in this area.



Code:
Console.Writeline(a.ToString)



for example. And it will be in the Output window.
  • | Post Points: 5
travis_abrahamson
Top 50 Contributor
California
Since 3/30/2005
Posts 2,082
Reputation 18,025
vbCity Team
To add additional information:

1. Keep in mind to use Console.WriteLine your application needs to be setup as a Console App Type (MyProject Application Type)
2. Debug.WriteLine will place the data in the Debug Window <-- These are removed from compiled version of application
3. Trace.WriteLine will place the data in a defined location. Trace allows you to define an output location and Trace can be configured to work in a compiled application (good for Debugging compiled versions of applications)

Travis
MCAD
God created the world in fifth normal form, but had to de-normalize it for us to understand
Posting Guidlines

  • | Post Points: 5
itmasterw
Top 500 Contributor
Amherst, NY
Since 4/23/2003
Posts 288
Reputation 5,025
Thank you, but I am making windows forms and not using the console window; that is why I used the debug.print, but it is now working here.
I used to use it in VB.Net but forgot how.
 
  • | Post Points: 5
XTab
Top 10 Contributor
Scotland
Since 2/21/2002
Posts 10,984
Reputation 118,563
ForumsAdministrator
vbCity Team
 
Quote:
to use Console.WriteLine your application needs to be setup as a Console App Type


Actually that's not strictly true. You can access the Output Window from a WinForms project in Debug Mode. Console.Writeline will write to it and be visible.

Go for View > Other Windows > Output from the IDE menu, if it's not visible by default.


If you want to stick to Debug.Print then you can access this with

Debug > Windows > Immediate.



  • | Post Points: 5
itmasterw
Top 500 Contributor
Amherst, NY
Since 4/23/2003
Posts 288
Reputation 5,025
Thank you you are right.
  • | Post Points: 5
Page 1 of 1 (6 items) | RSS
Copyright 1998-2015 vbCity.com LLC