Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Problem with Conditional Compilation (VB6)

Hi:

I have the following code at the start of my application:

#If conBetaVersion = 1 Then 'Beta version
    MsgBox "Beta Version"
    '#Const conUseExcel = 0
#Else                   'Production version
    MsgBox "Production Version"
    #Const conUseExcel = 1
#End If

#If conUseExcel = 1 Then
    MsgBox "Using Excel"
#Else
    MsgBox "Using ProEssentials"
#End If

If I run the code WITHOUT setting any Conditioal Compilation Arguments, it works as intended, i.e. it outputs the two messages, "Production Version" then "Using Excel".

When I set the Conditioal Compilation Arguments
field to "conBetaVersion=1" (without the quotes), it outputs the message "Beta Version" (as expected).
But it then also outputs the message "Using Excel".

I cannot work out why this is happening!

Regards

Leigh

0
LeighWardle
Asked:
LeighWardle
1 Solution
 
marconovaroCommented:
I think that the problem is related to the fact that you just _defined_ the conUseExcel, and is independant from the value of the constant itself.

Try this:

#If conBetaVersion = 1 Then 'Beta version
   MsgBox "Beta Version"
#Else                   'Production version
   MsgBox "Production Version"
   #Const conUseExcel = 1
#End If

#If conUseExcel = 1 Then
   MsgBox "Using Excel"
#Else
   MsgBox "Using ProEssentials"
#End If
0
 
EDDYKTCommented:
Because conUseExcel is never defined anywhere.
0
 
EDDYKTCommented:
Try this

Set your Conditioal Compilation Arguments to

conBetaVersion = 1 : conUseExcel = 0



#If conBetaVersion = 1 Then 'Beta version
   MsgBox "Beta Version"
#Else                   'Production version
   MsgBox "Production Version"
#End If

#If conUseExcel = 1 Then
   MsgBox "Using Excel"
#Else
   MsgBox "Using ProEssentials"
#End If
0
 
DanRollinsCommented:
Hi LeighWardle,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept marconovaro's comment(s) as an answer.

LeighWardle, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
NetminderCommented:
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now