Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to tell if running in development mode.

Posted on 2001-06-14
4
129 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 70

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 6192234
0
 
LVL 5

Expert Comment

by:rkot2000
ID: 6192237
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
ID: 6192282
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
ID: 6192351
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

860 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