#include equilvelant

  • Thread starter Thread starter Mike Fellows
  • Start date Start date
M

Mike Fellows

ok my code that im doing in .net is now starting to look fairly complicated,
what started out as a small project has grown and grown
and its time for some house keeping of my code

im trying to implement a .h (c++) file for use of a better word

all i want to do is have one file which has all of my major definations in
it

whereas in c++ i would do #include what do i do in vb.net?

i.e. i want


dim x as string = "abcdefg"
dim y as stirng = "hijklmno"

but i want to be able to include x and y in any other classes i make

ive tried and tried to do this in vb and just cant


Regards


Mike Fellows
 
Hello Mike

I'am not sure but Imports namespace.element might work.

Kind Regards
Jorge Cavalheiro
 
Mike,

Are you referring to inline including of files? If so, VB.net doesn't
support this.

Alternatives include the following:

1) Define Commonly used constants and methods in a module and then add the
module to your project. You won't be able to define code snippets in this
way - just commonly used methods, constants and variables. A copy of the
file will be created when you add it to your project.

2) Drag a code snippet to the toolbox in visual studio and rename it. When
you want to insert it, simply drag and drop.

3) As with (1), except design it so it can be put into a class library of
its own and then reference the class library.


HTH,

Trev.
 
Mike Fellows said:
ok my code that im doing in .net is now starting to look fairly
complicated, what started out as a small project has grown and
grown and its time for some house keeping of my code

im trying to implement a .h (c++) file for use of a better word

all i want to do is have one file which has all of my major
definations in it

whereas in c++ i would do #include what do i do in vb.net?

i.e. i want


dim x as string = "abcdefg"
dim y as stirng = "hijklmno"

but i want to be able to include x and y in any other classes i
make

ive tried and tried to do this in vb and just cant

Write class libraries to get reusable code.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
Thanks Guys

it seems strange that this is missing from VB
but since I only need to create a load of reuasble variables,
the creating of a module will do for now

Thanks

Mike Fellows
 
Mike Fellows said:
Thanks Guys

it seems strange that this is missing from VB
but since I only need to create a load of reuasble variables,
the creating of a module will do for now

Not really. Each language has its own set of features. VB is a Microsoft
product (well now it is.. Used to be Thunderbird or something like that in
the 1.0 incarnation) and C was a Bell Labs product. Developed for 2
entirely different reasons and shared nothing incommon until recently. =)

So not really strange at all. =)

-CJ
 
Mike Fellows said:
Thanks Guys

it seems strange that this is missing from VB
but since I only need to create a load of reuasble variables,
the creating of a module will do for now

Thanks

Mike Fellows

Missing what? Its really unnecessary in VB. You dont need to use #include because you can just
include the "header file" in the project and use its public variables, functions, etc.
 
Hi CJ,

Very strong and very very good, there is so much in that sentence from you
without that it is written..

Cor
 
....Detecting flame....

.... inconclusive....

I think this is good. =) But not really sure sometimes. =)

without that it is written..


is throwing me off... could you explain a little?

Thanks,
CJ
 
Hi CJ,
...Detecting flame....
Did I do that ever to you?
You see me seldom do that only to Herfried sometimes and he knows than that
it is just for fun.
I think this is good. =)
Yes, but I cannot explain because than your messages looses its power.

:-)

Cor
 
Cor said:
Hi CJ,

Did I do that ever to you?
You see me seldom do that only to Herfried sometimes and he knows than that
it is just for fun.

Rough week. =) Recently I've been charged with developing an ODBC driver
for a propertary database...

Hmmm.... CJ doesn't know how to write an ODBC driver, but I do have a
library by the OEM that gives me all my table calls etc... So I'm a little
paranoid about everything right now.

And no, you have never flamed me, maybe just commented when I was a little
out of line. And obviously nothing wrong with that. =)
Yes, but I cannot explain because than your messages looses its power.

:-)

Understood and thank you. =)
 
hey instead of using the module u could put those variables in some base
class, make them protected and inherits tha class in any other class where
you want those variables. This is the way you can use variables by
declaraing them once. Ok as far as the header file thing goes, mainly the
header file in c++ is used to contain function prototypes. What you can do
to simulate this in vb.net is first design the interface of your class and
write an interface class. Than implement that interface any where you like.
 
Mike,

Are you referring to inline including of files? If so, VB.net doesn't
support this.

Alternatives include the following:

1) Define Commonly used constants and methods in a module and then add the
module to your project. You won't be able to define code snippets in this
way - just commonly used methods, constants and variables. A copy of the
file will be created when you add it to your project.

Not necessarily, you can chose to link to the file, so that all projects
that use it share the same copy (hit the little arrow on the Open button
for this choice).
 
ok my code that im doing in .net is now starting to look fairly complicated,
what started out as a small project has grown and grown
and its time for some house keeping of my code

im trying to implement a .h (c++) file for use of a better word

all i want to do is have one file which has all of my major definations in
it

whereas in c++ i would do #include what do i do in vb.net?

i.e. i want


dim x as string = "abcdefg"
dim y as stirng = "hijklmno"

but i want to be able to include x and y in any other classes i make

ive tried and tried to do this in vb and just cant


Regards


Mike Fellows

As others have said, this isn't possible from VB.NET - at least in the
same way. Putting these in a module that is shared or in a class
library is probably the easiest way to go... But, there is another
alternative. The VB.NET compiler does understand the concept of
modules. Modules are small chunks of compiled code that can be inserted
into assemblies - together these can make up multifile assemblies. Just
because an assembly is usually just a single file, doesn't mean it has
to be :) The difficulty is that the IDE doesn't understand
them, so to use them you have to compile from the command line.
 
Not necessarily, you can chose to link to the file,
so that all projects that use it share the same
copy (hit the little arrow on the Open button
for this choice).

You learn something new every day ;) Cheers for the tip.

Trev.
 
* "Cor said:
Very strong and very very good, there is so much in that sentence from you
without that it is written..
ACK.

VB's codename was "Thunder".

;-)
 
* "Cor said:
Reminds me that CJ said that he had a problem with Guru, is that something
the same as Gnu.

Guru is a newsreader? I never heard this name...

My newsreader's name is "Gnus" (it runs in XEmacs).
 
Back
Top