473,503 Members | 13,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional include

Hi

Is there a way to conditionally include parts of code in a vb.net project? I
am creating an app for two clients with slightly different requirements. I
figure if I can set the condition at the top of the project, I can compile
the same app for either of the clients.

Thanks

Regards
Nov 20 '05 #1
3 1603
Hi John,

You can use conditional compiler directives:

Here's an example from MSDN:

#Const CustomerNumber = 36
#If CustomerNumber = 35 Then
' Insert code to be compiled for customer # 35.
#ElseIf CustomerNumber = 36 Then
' Insert code to be compiled for customer # 36.
#Else
' Insert code to be compiled for all other customers.
#End If

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to conditionally include parts of code in a vb.net project? I am creating an app for two clients with slightly different requirements. I
figure if I can set the condition at the top of the project, I can compile
the same app for either of the clients.

Thanks

Regards


Nov 20 '05 #2
"John" <jo**@nospam.infovis.co.uk> schrieb
Is there a way to conditionally include parts of code in a vb.net
project? I am creating an app for two clients with slightly different
requirements. I figure if I can set the condition at the top of the
project, I can compile the same app for either of the clients.


http://msdn.microsoft.com/library/en...tionPortal.asp
--
Armin

Nov 20 '05 #3
John,
You can use the Conditional Compilation to include or exclude parts of your
code.

For details see:

http://msdn.microsoft.com/library/de...tionPortal.asp

There is also a ConditionalAttribute that you can apply to a function so
that is it only called during certain builds of your project.

<Conditional("DEBUG")> _
Public Sub Dump()

End Sub

You can call the Dump function unconditionally within your program, during
Debug builds the function will be called and executed, during release builds
the function will not be called. This is how the Debug.WriteLine function
performs its magic.

Hope this helps
Jay

"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl...
Hi

Is there a way to conditionally include parts of code in a vb.net project? I am creating an app for two clients with slightly different requirements. I
figure if I can set the condition at the top of the project, I can compile
the same app for either of the clients.

Thanks

Regards

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2443
by: Steven T. Hatton | last post by:
I've made no secret of the fact that I really dislike the C preprocessor in C++. No aspect of the language has caused me more trouble. No aspect of the language has cause more code I've read to be...
28
3414
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
12
2461
by: wanghz | last post by:
Hi, Could I ask some questions about the conditional compilaion? Suppose I have three simple files: a.c, b.c and c.h /* --------a.c--------- */ #include <stdio.h> #include "c.h" int...
7
2319
by: John Dolinka | last post by:
I have a project of several files with #defines to setup a conditional compile. I would like to put these #defines in a single file and change the conditional compile from this one file with the...
10
3071
by: Dave | last post by:
I'm a C++ programmer of many years, trying to get my feet wet in C#. I have a question about conditional compilation. In C++, I would sometimes define a constant in an include file, and then...
5
2890
by: paulo | last post by:
Can anyone please tell me how the C language interprets the following code: #include <stdio.h> int main(void) { int a = 1; int b = 10; int x = 3;
43
7537
by: dev_cool | last post by:
Hello friends, I'm a beginner in C programming. One of my friends asked me to write a program in C.The purpose of the program is print 1 to n without any conditional statement, loop or jump. ...
16
3719
by: Alan Jones | last post by:
Hello everyone, any help would be greatly appreciated. :) What I'm trying to do may not be advisable, but here goes... I want a page named signature.php to appear conditionally as an include...
4
2215
by: rocketeer | last post by:
I've a set of Javascript classes that maintain state. For example, gm.js might be: var GroupManager { groups: {} }; Over time I add new groups to the list: GroupManager.groups = myGroup; ...
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.