How can I do something similar to the following C code in VB 6?
#ifdef _DEBUG_
// do things
#else
// do other things
#end if
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s pretty much the same as the other languages that you’re used to. The syntax looks like this:
It’s easy to remember if you just remember that the syntax is exactly the same as the other flow-control statements in VB 6, except that the compile-time conditionals start with a pound sign (
#).The trick is actually defining the
DEBUG(or whatever) constant because I’m pretty sure that there isn’t one defined by default. There are two standard ways of doing it:Use the
#Constkeyword to define the constant at the top of each source file. The definition that you establish in this way is valid throughout the entire source module. It would look something like:Set the constant in the project’s properties. This would define a constant that is valid throughout the entire project (and is probably what you want for a “Debug” mode indicator).
To do this, enter something like the following in the “Conditional Compilation Constants” textbox on the “Make” tab of the “Project Properties” dialog box:
You can define multiple constants in this dialog by separating each of them with a colon (
:):Remember that any constant which is not defined is assumed to be 0.