Solved

How to tell if running in development mode.

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

919 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

20 Experts available now in Live!

Get 1:1 Help Now