If you do not want debugging statements included in the application you distribute to users, use conditional compilation to conveniently delete these statements when the Make EXE File command is used.
For example:
Sub Assert(Expr As Boolean, Msg As String)
If Not Expr Then
MsgBox Msg
End If
End Sub
Sub AProcedure(intX As Integer)
# If fDebug Then
Assert intX < 10000 and intX > 0, _
"Argument out of range"
# End If
' The code can now assume the correct value.
End Sub
Because the call to the Assert procedure is conditionally compiled, it is only included in the .exe file if fDebug is set to True. When you compile the distribution version of the application, set fDebug to False. As a result, the .exe file will be as small and fast as possible.
Note Since the release of Visual Basic version 5.0, it is no longer necessary to create your own Assert procedures. The Debug.Assert statement performs the same function and is automatically stripped from the compiled code. See "Verifying Your Code with Assertions" later in this chapter for more information.