VB.NET ""Include" statement missing?

B

bill salkin

I have several lengthly VB.NET Enums that I'd like to
store in seperate files (not in the body of my main
routine.) I hoped that VB.NET had an "Include" statement
(like C) who presence indicates the content of a file is
inserted at this point in the code. But I couldn't find a
VB.NET "Include". Can I do what I want in VB.NET?

TIA,

Bill
 
A

Armin Zingler

bill salkin said:
I have several lengthly VB.NET Enums that I'd like to
store in seperate files (not in the body of my main
routine.) I hoped that VB.NET had an "Include" statement
(like C) who presence indicates the content of a file is
inserted at this point in the code. But I couldn't find a
VB.NET "Include". Can I do what I want in VB.NET?

Including is not a good idea because copies of the code will be part of each
project.

Create a library and set a reference to the library from any project that
needs it.
 
H

Herfried K. Wagner [MVP]

* "bill salkin said:
I have several lengthly VB.NET Enums that I'd like to
store in seperate files (not in the body of my main
routine.) I hoped that VB.NET had an "Include" statement
(like C) who presence indicates the content of a file is
inserted at this point in the code. But I couldn't find a
VB.NET "Include". Can I do what I want in VB.NET?

You don't need an 'include' (it doesn't even exist in VB.NET). Just
declare the enum, for example, as 'Public', and you can use it in other
places in the project.
 
J

Jay B. Harlow [MVP - Outlook]

Bill,
In addition to the other comments. You can add a new "code file" to your
project, such as "myenums.vb" and add all your enums to this "code file".

Creating a class library (.dll) with the above "code file" will allow you to
share the enum between projects. If you only have a single project using a
code file may be easier. Note you can use "Link file" to create a link to a
single file from multiple projects, which avoid the class library (.dll)
altogether.

In VS.NET 2003:
- To add a "code file" use "Project - Add New Item - Code File".
- To link to a file, use "Project - Add Existing Item - Link File" (Link
file is on the drop down next to the Open button).

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top