Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDetermine if the program is running in the IDE or an executable.
KeywordsIDE, executable, run, running
CategoriesTips 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated