Visual Basic Helper Routines
Pure VB: Determine if App is Running in the IDE
     
Posted:   Monday March 25, 2002
Updated:   Monday December 26, 2011
     
Applies to:   VB4-32, VB5, VB6
Developed with:   VB6, Windows XP
OS restrictions:   None
Author:   Mathew Curland
     
Related:   IsInIDE
IsInIDE (api version)
     
 Prerequisites
None.

Although a plethora of different code examples prevail, this is the correct method of determining whether the current application execution is taking place in the Visual Basic IDE (design time) or as an exe (runtime), by Mathew Curland, VB God.

In discussing this approach over others (predominantly the Division by 0 error trap), Matt states: After being bitten a couple of times several years ago, I've always considered a function that expects an error with On Error Resume Next but no On Error GoTo 0 or Err.Clear to be a bug waiting to happen, because a calling routine that uses On Error Resume Next and checks the Err state will get a false error report.

 BAS Module Code
None.

 Form Code
In any project add the following code, and call the IsInIDE() function. If positioned in a BAS module or class, change the IsInIDE() scope to Public:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Function IsInIDE() As Boolean
   Dim x As Long
   Debug.Assert Not TestIDE(x)
   IsInIDE = x = 1
End Function


Private Function TestIDE(x As Long) As Boolean
   x = 1
End Function
 Comments

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter