|
|
Title | Determine whether the program is running in the IDE or as a compiled executable by using Debug.Assert |
Keywords | run mode, IDE, executable, Debug.Assert |
Categories | Miscellany, Software Engineering |
|
|
Thanks to C. K. Lam.
Use Debug.Assert to run a function that sets the debug value. The Debug.Assert statement is removed from copmiled executables so it only executes when you run in the IDE.
|
|
' Flag for debug mode
Private bDebugMode As Boolean
' Set bDebugMode to true. This happens only
' if the Debug.Assert call happens. It only
' happens in the IDE.
Private Function InDebugMode() As Boolean
bDebugMode = True
InDebugMode = True
End Function
' Set the bDebugMode flag.
Private Sub SetDebugMode()
' This will only be done if in the IDE
Debug.Assert InDebugMode
End Sub
Private Sub Form_Load()
' See if we are running in the IDE.
SetDebugMode
' Tell the user.
If bDebugMode Then
Label1.Caption = "In the development environment"
Else
Label1.Caption = "In a compiled executable"
End If
End Sub
|
|
|
|
|
|