| | Submitted on: 6/25/2003 4:38:46 PM
By: Jay Goldberg
Level: Intermediate User Rating: Unrated Compatibility:VB 6.0
Users have accessed this article 391 times. | |
| | Often times when writing an application, I want the user to be prompted when he quits the program (ie. "Are you sure you want to quit?"). The only thing about this is when I am debugging the program and using it myself in VB's IDE, I find this messagebox to be annoying. So I wrote this little function that will return TRUE if the app is running in the IDE, and FALSE if it running as a EXE. | |
|
Terms of Agreement:
By using this article, you agree to the following terms...
1) You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
2) You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
3) You may link to this article from another website, but ONLY if it is not wrapped in a frame.
4) You will abide by any additional copyright restrictions which the author may have placed in the article or article's description. |
Function InDesignMode() As Boolean
On Error GoTo Err
Debug.Print 1 / 0
InDesignMode = False
Exit Function
Err:
InDesignMode = True
End Function
| |
|
Report Bad Submission |
|
|
Your Vote! |
See Voting Log |
|
Other User Comments |
6/25/2003 4:40:15 PM:CrazyJew I've previously posted this Function,
but I saw someone somewhere asking for
one of this nature so I will re-post.
Enjoy.
|
6/25/2003 8:48:05 PM:noroom i guess this works only because
debug.print lines are ignored when
compiled as an exe, right?
|
6/26/2003 4:02:20 AM:Andrew Murphy No, it errors because of division by 0,
mathmatically impossible
|
6/26/2003 7:53:23 AM:VB-ASP-Coder USING CONDITIONAL COMPILATION
You can
use conditional compilation to
selectively run blocks of code. The
following sample macro uses conditional
compilation:
Sub Test()
#Const Debugging = 1
Dim Name
As String: Name = "Nancy"
' If
you are debugging, change the Debugging
constant to 0.
#If Debugging = 0
Then
' This debug statement
is not executed unless the Debugging
' constant is equal to zero.
Debug.Print Name
#End
If
Name = "Kerry"
End
Sub
The behavior of the
#If...Then...#Else conditional
compilation directive is the same as
the If...Then...Else statement.
However, code that is excluded during
conditional compilation is completely
omitted from the final executable file;
so, using conditional compilation has
no size or performance disadvantages
|
6/26/2003 9:20:38 AM:Techni Rei Myoko ever tried using the app.logmode?
0 =
in vb
1 = not
|
|
Add Your Feedback! |
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.
NOTICE: The author of this article has been kind enough to share it with you. If you have a criticism, please state it politely or it will be deleted.
For feedback not related to this particular article, please click here. |
|