Discussion Locked

Visual Basic

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

In visual basic 6.0 I want know that I am running code from exe or source code. Is there is function that can tell me or any other trick.

Let me know.

Adrehman
Developer
ZRG International

7 replies

by donq

Pure Visual Basic always creates an executable when compiled. If you don't select compile when you are through coding, VB automatically compiles you work before executing. Read your on'line Help under "compile".

by peyison

An easy way to do this is to use a compiler directive.

There are two ways to create one:

Use #Const in a code module

Or fill in the "Conditional Compilation Arguments" box on the "Make" tab of the "Project Properties" dialog

The difference is scope. The first will only be available to the module it is declared in, while the second will be available from anywhere in the project.

Here's how to use it:

In a code module:
--------------------
#Const InVBE=True

#If InVBE Then
'code for only if you're in the VB editor

#Else

'code for only when you're running from the EXE

#End If
-----------
When you're working in the VBE, set the constant to true. When you're ready to compile, set it to false.

If you use the "Conditional Compilation Arguments" box, you'd enter: InVBE=True

Hope this helps.

This discussion is closed to new replies.