Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Conditional Compilation

Posted on 2004-08-24
4
Medium Priority
?
263 Views
Last Modified: 2010-04-23
I was wondering if there was an equivalent way to do this C++ code in VB.

#if _DEBUG
      #define RunMethod(x) RunMethodA(x)
#else
      #define RunMethod(x) x
#endif

The main reason I wish to do this is I will be writing a testing suite and I will be writing these functions into if statements
eg. if TestCondition(3>4) then
So when I compile it in Debug it will call TestCondition, but when it is compiled to Release mode it change to "if 3>4 then". The other reason I really need it done like this instead of just returning straight away from inside the TestCondition function if compiled in release mode is that the file which will contain the function shall be removed from the source before the Release version is compiled

0
Comment
Question by:Mike737
[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
  • 2
4 Comments
 
LVL 1

Author Comment

by:Mike737
ID: 11889446
Still doesn't solve my issue.
I need the #define specifically.

If I was to do it just as a #if,#else everytime for every if statment I write the extra number of lines I would have to write would be rediculous! I would be looking at an extra 300 lines in my code if I had 100 if statements in it.

I don't really think that just #if's by themselves are an acceptable soloution.

0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1000 total points
ID: 11893566
no you cannot do the above as code macros are not supported ...

you can however use the Conditional attribute on your classes (they will completely compile out including calls to them if symbol not set) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsconditionalattributeclasstopic.asp includes examples. This should do exactly what you are looking for.
0
 
LVL 1

Author Comment

by:Mike737
ID: 11899659
Looks like you are on the right track with that one.
Been able to get a nice little testing interface up and working with that one.

Absolutely awesome answer dude!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

705 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