Solved

Problem with Conditional Compilation (VB6)

Posted on 2002-06-27
5
323 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
5 Comments
 
LVL 6

Accepted Solution

by:
marconovaro earned 100 total points
Comment Utility
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
Comment Utility
Because conUseExcel is never defined anywhere.
0
 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
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
Comment Utility
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
Comment Utility
Per recommendation, force-accepted.

Netminder
EE Admin
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now