#define preprocessor directive
#define preprocessor directive
#define preprocessor directive
#define preprocessor directive
#define preprocessor directive
#define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive
#define preprocessor directive #define preprocessor directive
#define preprocessor directive
Go Back  Xtreme Visual Basic Talk > > > #define preprocessor directive


Reply
 
Thread Tools Display Modes
  #1  
Old 12-23-2011, 11:15 AM
jprg jprg is offline
Regular
 
Join Date: Dec 2008
Posts: 72
Default #define preprocessor directive


Hi,

I really like the #define preprocessor directive in C. Basically, it substitutes a symbol for a piece of code anywhere in the file.
Does VB.NET have this?

For example:
Code:
Dim numbers As String() = New String() {"One", "Two", "Three", "Four"}
Dim ActiveNumberIndex as Integer

#define ActiveNumber numbers(ActiveNumberIndex)

MsgBox(ActiveNumber)
Thanks.
Reply With Quote
  #2  
Old 12-23-2011, 02:17 PM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

No it doesn't, nor does VB6.

Preprocessor Macros (and include files) are one of the missing features that really irks me. Prior Microsoft Basics (QuickBasic and BASCOM/PDS) at least had include files.

One common use of macros in C is however supported and that is for creating aliases for datatypes (and class/structure definitions.) This is done with the Imports statement:

Imports scaler = System.Single

This is convenient because sometimes you want to be able to make a large-ish switch between an Single and Double, for example with Vector and Matrix structures that leverages operator overloading, something that Generics just can't reasonably do.

Code:
Imports scaler = System.Single
Structure Vector
  Public x, y, z As scaler
  ...
End Structure
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
#define preprocessor directive
#define preprocessor directive
#define preprocessor directive #define preprocessor directive
#define preprocessor directive
#define preprocessor directive
#define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive #define preprocessor directive
#define preprocessor directive
#define preprocessor directive
 
#define preprocessor directive
#define preprocessor directive
 
-->