Solved

How to tell if running in development mode.

Posted on 2001-06-14
4
130 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
[X]
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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

733 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