Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
XML RSS Feed
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleDetermine whether the program is running in the IDE or as a compiled executable by using Debug.Print
Keywordsrun mode, IDE, executable, Debug.Print
CategoriesMiscellany, 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
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated