writing own debug messages to debug window

  • Thread starter Thread starter Thomas Pecha
  • Start date Start date
T

Thomas Pecha

Sorry for all who think this is easy, I was not able to handle this

Coming from VB6 where with simple

debug.print strAString

you could write to debug window, I am totalling failing in vb.net 2003
The sample in the help file does not work. I tried now for days ...

Pls could anybody post a sample, including necessary imports and so on -
thank you so much in advance
 
Hi Thomas

Debug.WriteLine(strAString)

The string will appear in the Output window, as opposed to the command
window as it does in VB6.

HTH

Charles
 
TNX, but did not work
does this also work if I do a PPC App

The help says :

Public Shared Function Main(args() As String) As Integer
Debug.Listeners.Add(New TextWriterTraceListener(Console.Out))
Debug.AutoFlush = True
Debug.Indent()
Debug.WriteLine("Entering Main")
Console.WriteLine("Hello World.")
Debug.WriteLine("Exiting Main")
Debug.Unindent()
Return 0
End Function 'Main

but then I get a build error because TextWriterTraceListener is not known (I
imported diagnostics)

big ???? here - sorry
 
Thomas,
As Charles stated, Print is now Write & WriteLine in VB.NET

Debug.Write(strAString)
Debug.WriteLine(strAString)

In addition to the Debug class, there is also a Trace Class. Normally calls
to the Debug class are removed during release builds, while calls to the
Trace class are available in both Debug & Release builds.

In addition to Write & WriteLine both classes have: WriteIf, WriteLineIf,
Indent, Unindent, Assert, and Fail methods. Which allow for a richer
formatting of the output.

Oh! Write, WriteLine, WriteIf, and WriteLineIf support giving a category,
which is useful to label your output.

Debug.WriteLine(strAString, "strAString")
Debug.WriteLine(index, "index")

Trace.WriteLine(strAString, "strAString")
Trace.WriteLine(index, "index")

Hope this helps
Jay
 
I'm sorry, I don't know what you mean by a PPC App. Do you mean a console
application? If so, I have just created a new console app and added a single
line to main:

Module Module1
Sub Main()
Debug.WriteLine("Hello world")
End Sub
End Module

It compiles and runs, and outputs Hello world to the Output window. Is that
what you are after?

Charles
 
Thomas,
What kind of app are you building? A .NET Compact Framework app?

TextWriterTraceListener is not supported on the .NET Compact Framework.

When looking at help, check the "Requirements - Platforms" section at the
bottom of the page.

Remove that line along with the Indent & Unindent and your app 'should'
work. Again check the help for what classes & members are supported on which
platform.

Hope this helps
Jay
 
Thomas Pecha said:
Coming from VB6 where with simple

debug.print strAString

you could write to debug window, I am totalling failing in vb.net 2003
The sample in the help file does not work. I tried now for days ...

Use 'System.Diagnostics.Debug.WriteLine' instead.
 
Nope.
Thomas Pecha said:
TNX, but did not work
does this also work if I do a PPC App

The help says :

Public Shared Function Main(args() As String) As Integer
Debug.Listeners.Add(New TextWriterTraceListener(Console.Out))
Debug.AutoFlush = True
Debug.Indent()
Debug.WriteLine("Entering Main")
Console.WriteLine("Hello World.")
Debug.WriteLine("Exiting Main")
Debug.Unindent()
Return 0
End Function 'Main

but then I get a build error because TextWriterTraceListener is not known (I
imported diagnostics)

big ???? here - sorry
 
Back
Top