Am I running in the IDE?
The proper way to find out whether your code is running in the IDE or was compiled
Rate Am I running in the IDE?
(7(7 Vote))
'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
Am I running in the IDE? Comments
No comments yet — be the first to post one!
Post a Comment