
HOWTO: Tell Whether an App Runs in VB Design Environment
If you use _this_ method, you can even tell from your ActiveX DLL is it is
being called from the IDE:
Public Function VBDesignMode() As Boolean
'
' If VB5.EXE is running in the current process space, return TRUE
'
' If VB5.EXE is running as another process, GetModuleHandle returns 0
Dim hModule As Long
hModule = GetModuleHandle("VB5.EXE")
VBDesignMode = (hModule > 0)
End Function
I wrote this when I realized that the "Debug.print 0 / 0" method will fail
if a compiled component needs to know if it's is being used in the IDE.
Jonas
TRION Technologies
Quote:
>You don't need to know a system variable, just use this simple Function:
>Function DesignTime() As Boolean
> On Error Resume Next
> Debug.Print 0 / 0
> If Err = 0 Then
> DesignTime = False
> Else
> DesignTime = True
> End If
>End Function
>The debug-object doesn't cause an div by zero error when running as
>standalone-EXE!
>Tricky, eh?
>> There is a system variable that you could use for a conditional compile
>that
>> will tell your program whether it is running as a standalone EXE or from
>> within the IDE.