Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Sep 8, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Determine if Your Program is Running Within VB's IDE

Sometimes it is useful to know if your program is running within Visual Basic's Integrated Development Environment (IDE) or as a standalone EXE. This routine returns True if the program is running within VB's IDE:
 Public Function RunningInIDE() As Boolean
	'Assume running as EXE for now
	RunningInIDE = False
	'Trap errors
	On Error GoTo RunningInIDEErr
	'Divide by zero (fails within IDE)
	Debug.Print 1 / 0
	'Exit if no error
	Exit Function
	'We get error if Debug.Print was
	'evaluated (i.e. running in the VB IDE)
	RunningInIDE = True
End Function

RunningInIDE performs a division by zero in a Debug.Print statement. Within the IDE, this causes a divide overflow, which the function traps in an error handler. When the program is run as a standalone EXE, Debug.Print statements are not evaluated and no error occurs.

Jeffrey Sahol
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date