O'Reilly logo

Application Development Using Visual Basic® and .NET by Dana L. Wyatt, Peter Thorsteinson, Robert J. Oberg

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

Using Switches to Enable Diagnostics

Switches give you finer grain control over the diagnostic output. You can use the BooleanSwitch class to turn output on or off based on the value of its Enabled property.

The TraceSwitch class gives you five hierarchical levels of control for its Level property: TraceError, TraceWarning, TraceInfo, TraceVerbose, and Off. These values are part of the TraceLevelEnumeration. Setting a lower Trace level means that the higher ones are set as well. For example, if the TraceWarning level is set, both the TraceError and TraceWarning levels are enabled.

 DebugBooleanSwitch.Enabled = True Debug.WriteLineIf(DebugBooleanSwitch.Enabled, _ "Debug Boolean Switch enabled!") ... Trace.WriteLineIf(TraceLevelSwitch.TraceError, ...

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