Debug.Assert Method |
object.Assert booleanexpression
object
Use: Required
Data Type: Debug object
Always evaluates to the Debug object.
booleanexpression
Use: Required
Data Type: Boolean
Expression that evaluates to a Boolean value.
None.
Conditionally suspends program execution and transfers control to the Immediate window if the value of booleanexpression is False.
booleanexpression must evaluate to a Boolean value.
If booleanexpression is False, program execution is suspended and control transfers to the Immediate window.
Program execution can be resumed by pressing the Continue button on either the Standard or Debug toolbars.
The Assert method is available only in Visual Basic; the Debug object in the VBA development environment doesn't support the Assert method.
Assert is typically used when debugging to test an expression that should evaluate to True. If it doesn't, the Immediate window can be used to investigate why the test failed.
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 never produces a runtime error if the call to it is inappropriate, nor does it suspend program execution outside of the VB IDE. Because of this, you don't have to remove Debug.Assert statements from finished code or separate them with conditional #If...Then statements.