Solved

How to tell if running in development mode.

Posted on 2001-06-14
4
126 Views
Last Modified: 2010-05-02
I pop up a message box when the program starts, but I don't want it to come up if I am running from the IDE.  How can I tell if I am running from an Exe or from the IDE?

Thanks
0
Comment
Question by:beckingh
4 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 50 total points
Comment Utility
0
 
LVL 5

Expert Comment

by:rkot2000
Comment Utility
option #1
Private Sub Form_Load()
  MsgBox IsIDE
End Sub

Private Function IsIDE() As Boolean
  On Error Resume Next
  Debug.Assert 1 / 0
  If Err.Number = 0 Then
    IsIDE = False
  Else
    IsIDE = True
  End If
End Function

Option #2
Conditional Compilation
0
 

Expert Comment

by:abhijitmathure
Comment Utility
I had a similar problem and found the solution on MSDN itself. Here is how it works.
1) Keep the exe name different from the project.
2) If the exe has the same name as the project, use the
GetModuleFileName API function to determine if your program is running from the IDE or from a compiled version. GetModuleFileName retrieves the full path and filename for the executable file containing the specified module. If the function returns a path to the Visual Basic file, VB5.EXE, then the program is running in the IDE. Otherwise, the program is running from an executable file.
0
 
LVL 4

Author Comment

by:beckingh
Comment Utility
Here's the code I ended up using.  Thanks all.


Function IsIDE() As Boolean
   On Error Resume Next
   Debug.Print 1 / 0
   IsIDE = Err.Number <> 0
   Err.Clear
End Function
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now