Am I running in the IDE?
The proper way to find out whether your code is running in the IDE or was compiled
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
'this code goes into a class named cEnvironment
Option Explicit
Public Enum eEnvironment
EnvironIDE = 1
EnvironCompiled = 2
End Enum
Public Property Get QueryEnvironment() As eEnvironment
QueryEnvironment = EnvironCompiled
Debug.Assert Not SetToIDE(QueryEnvironment)
End Property
Private Function SetToIDE(Env As eEnvironment) As Boolean
Env = EnvironIDE
End Function
'make QueryEnvironment the default property of class cEnvironment
'------------------------------------------
'and then use this anywhere in your code
Private Sub Something()
Dim Environment As New cEnvironment
Print IIf(Environment = EnvironIDE, " I am running in the IDE", _
" Somebody had mercy and compiled me")
' you don't normally print the result, so you might type this...
' If Environment =
' ..and you will see the two possibilities in VB's popup
End Sub
Original Comments (3)
Recovered from Wayback Machine