Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting whether app is compiled or running in IDE

Status
Not open for further replies.

apkohn

Technical User
Nov 27, 2000
62
AU
Is there any way to detect whether an application is running in debug mode in the IDE, or whether it is a compiled program?
 
The hard(?) way is through an API:
The akward VB way could be as follows:

Private Function IsExecutable() As Boolean
On Error GoTo PROC_ERROR
Debug.Print 1/0
IsExecutable = True

PROC_EXIT:
Exit Function

PROC_ERROR:
IsExecutable = False
GoTo PROC_EXIT

End Function


The function is based in the fact that the Debug method only executes within the IDE envinronment. When the program is compiled the calls to the Debug method are omitted, so the code falls through and the IsExecutable = True statement is executed.

Within the IDE, the Debug.Print 1/0 is executed and provokes an error. Control is then switched to the PROC_ERROR label, which subsequently sets the IsExecutable = False
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Thanks RV. I ended up using the API call,and it works great
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top