Name

Debug.Assert Method

Class

System.Diagnostics.Debug

Syntax

Debug.Assert(booleanexpression[[, string1], string2])
booleanexpression

Use: Required

Data Type: Boolean

Expression that evaluates to a Boolean value.

string1

Use: Required

Data Type: String

String to output if booleanexpression is False.

string2

Use: Required

Data Type: String

Detailed string to output. If booleanexpression is False, string2 is output to Output window.

Return Value

None

Description

Outputs messages to the Output window if the condition is False

Rules at a Glance

booleanexpression must evaluate to a Boolean value.

Programming Tips and Gotchas

  • Assert is typically used when debugging to test an expression that should evaluate to True.

  • Debug.Assert executes only when an application is run in the design-time environment; the statement has no effect in a compiled application. This means that Debug.Assert will never produce a runtime error if the call to it is inappropriate, nor will it suspend program execution outside of the VB IDE. Because of this, you do not have to remove Debug.Assert statements from finished code or separate them with conditional #If...Then statements.

Get VB .NET Language in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.