NamespaceSystem.Diagnostics CreatableNo DescriptionThe Debug class is used to send messages to the Output Window (called the Immediate Window in VB 6). The Debug class can also send output to other targets (such as text files) referred to as listeners. See the Debug.Listeners Property entry for additional information. The Debug class also allows you to check program logic with assertions. Because the Debug class's members are shared, you do not need to instantiate a Debug object before accessing its members. The following code fragment, for instance, illustrates a call to the Debug object's WriteLine method: Debug.WriteLine(soFar & " iterations through the loop") The following table lists some of the more useful and interesting members of the Debug class. Those marked with an asterisk (*) have separate entries in this chapter.
Usage at a GlanceThe Debug class features only work in the design-time environment; the statement has no effect in a compiled application. You do not have to remove Debug-related features from your code before release. Version DifferencesThe VB 6 Debug object had only two methods: Assert and Print. The .NET Assert method is similar to the VB 6 method of the same name, except that the .NET version displays a message if an expression is False, while the VB 6 version suspends program execution. In .NET, the VB 6 Print method is removed, replaced by the Write, WriteIf, WriteLine, and WriteLineIf methods. See AlsoDebug.Assert Method, Debug.Write Method, Debug.WriteLine Method |