|
|
Title | Determine whether the program is running in the IDE or as a compiled executable by using Debug.Print |
Keywords | run mode, IDE, executable, Debug.Print |
Categories | Miscellany, Software Engineering |
|
|
Execute a Debug.Print statement that generates an error, using an On Error statement to catch the error. In a compiled executable, the Debug.Print statement is removed so the error doesn't occur.
|
|
Private debug_mode As Boolean
' Set debug_mode.
Private Sub SetDebugMode()
On Error GoTo InIDE
Debug.Print 1 / 0
debug_mode = False
Exit Sub
InIDE:
debug_mode = True
End Sub
Private Sub Form_Load()
' See whether we're in the IDE.
SetDebugMode
' Tell the user.
If debug_mode Then
Label1.Caption = "In the development environment"
Else
Label1.Caption = "In a compiled executable"
End If
End Sub
|
|
|
|
|
|