Solved

Problem with Conditional Compilation (VB6)

Posted on 2002-06-27
5
335 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 100 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON Response and request in VB6 application 11 823
Access 2013 combo box not working 3 60
VB6 - Convert HH:MM into Decimal 8 70
Added a column screws up code 5 69
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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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