O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Debug Class

Namespace

System.Diagnostics

Createable

No

Description

The Debug object is used to send messages to the Output window (formerly called the Immediate window). The Debug object can also send output to other targets, such as text files, referred to as listeners. See the Debug.Listeners Property entry. The Debug class also allows you to check program logic with assertions.

Because the Debug class’ members are shared, you do not need to instantiate the Debug object before accessing its members. The following code fragment, for instance, illustrates a call to the Debug object’s WriteLine method:

Debug.WriteLine(intCount & " iteration through the loop")

Debug class members marked with an plus sign (+) are discussed in detail in their own entries.

Public Shared Properties

AutoFlush +
IndentLevel +
IndentSize +
Listeners +

Public Shared Methods

Assert +
Close +
Fail
Flush +
Indent +
Unindent +
Write +
WriteIf +
WriteLine +
WriteLineIf +

VB.NET/VB 6 Differences

The VB 6 Debug object has only two methods, Assert and Print. The VB.NET Assert method is similar to the VB 6 method, except that the latter displays a message if an expression is False, while the former suspends program execution. In VB.NET, the VB 6 Print method is gone, replaced by the Write, WriteIf, WriteLine, and WriteLineIf methods.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required