Compile pragma only in release


Does a pragma (#const) exist that is true only when working in debug mode (under VB environement) or the reverse ?

Because i need a portion of code to be compiled only when building the release module but not compiled (or not runned) when i am working under VB environement.

THanks
eric3333Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HoweverCommaCommented:
This will let you perform opertions based on the value of a boolean that can only get set to true if the IDE is active.
Just call it in formload or you own init routine. Code in question will still be compiled but will not execute if the boolean condition is not met.

'You can check this flag anywhere in your code
Public IsIDE As Boolean
Private Sub Form_Load()
    IsIDE = False
    'This line is only executed if
    'running in the IDE and then
    'returns True
    Debug.Assert CheckIDE
    'Use the IsIDE flag anywhere
    If IsIDE Then
        MsgBox ("Running under IDE")
    Else
        MsgBox ("Running as EXE")
    End If
End Sub
 
Private Function CheckIDE() As Boolean
    'This function will never be executed in an EXE
    IsIDE = True        'set global flag
    'Set CheckIDE or the Debug.Assert will Break
    CheckIDE = True
End Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
eric3333Author Commented:
Hi

Yes a good idea.
Will take that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.