Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problem with Conditional Compilation (VB6)

Posted on 2002-06-27
5
Medium Priority
?
337 Views
Last Modified: 2007-11-27
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
Comment
Question by:LeighWardle
[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
5 Comments
 
LVL 6

Accepted Solution

by:
marconovaro earned 400 total points
ID: 7115738
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
 
LVL 26

Expert Comment

by:EDDYKT
ID: 7116086
Because conUseExcel is never defined anywhere.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 7116094
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
 
LVL 49

Expert Comment

by:DanRollins
ID: 7964649
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
 
LVL 5

Expert Comment

by:Netminder
ID: 8014901
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

719 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