|
|
Title | Determine if the program is running in the IDE or an executable. |
Keywords | IDE, executable, run, running |
Categories | Tips and Tricks, Software Engineering |
|
|
In an executable, Debug.Print statements are skipped (if they do not invoke functions). This program uses that fact to set the value of the InIDE variable appropriately.
|
|
Private InIDE As Boolean
Private Sub SetInIDE()
On Error GoTo DivideError
Debug.Print 1 / 0
InIDE = False
Exit Sub
DivideError:
InIDE = True
End Sub
Private Sub Form_Load()
SetInIDE
If InIDE Then
MsgBox "In the IDE"
Else
MsgBox "In an executable"
End If
End Sub
|
|
Formatted by
Neil Crosby
|
|
|
|
|
|