How to easily include pre-written code

L

Lee

Gang,
I have written several little functions that I use in multiple utilities
that I write. Everything is very simple, my use, no distribution. I want
to reference this code in some common utility .bas file and then reference
it/them in a VB.net project without having to copy and paste it into the
project. So that when one of those functions is referenced it will include
that code at compile time. How can I do this???

Thanks for any help.

Lee
 
G

Guest

Lee said:
I have written several little functions that I use in multiple
utilities that I write. Everything is very simple, my use, no
distribution. I want to reference this code in some common utility
.bas file and then reference it/them in a VB.net project without
having to copy and paste it into the project. So that when one of
those functions is referenced it will include that code at compile
time. How can I do this???

Create a DLL (library) of your code.
 
A

AMercer

I have written several little functions that I use in multiple utilities
that I write. Everything is very simple, my use, no distribution. I want
to reference this code in some common utility .bas file and then reference
it/them in a VB.net project without having to copy and paste it into the
project. So that when one of those functions is referenced it will include
that code at compile time. How can I do this???

Put all the code in one file, eg Utility.vb, which contains public module
utility, which contains your subs/functions. Put this file in a project
dedicated to developing and testing these functions. In the other .net
projects that need to use these functions, do this:

click Project
click Add Existing Item
browse to your utility.vb file, and select it
click the little down arrow symbol on the Add button
click Add as Link

This will do what you ask, but the more common solution is to make a dll out
of your utilities and reference it in other projects. Your common code will
be a part of all your projects, and there will be only one source file. A
change made to the file in one project will be seen by other projects, so be
careful.
 
C

Cor Ligthert[MVP]

Isn't there an incldue sort of option in vb.net?Where do you think OOP is for.

You create classes and as Spam Catcher in fact wrote and than you build them
in a DLL.

Then you can refrerence, import and instance them in your other projects and
use that.

There are of course as well snippets however that is in my idea more for
very often used simple syntax lines, although those are already made more
and more automatic

Cor
 
O

\(O\)enone

John said:
Isn't there an incldue sort of option in vb.net?

Sort of...

Select Project/Add Existing Item and then browse to the source file you want
to include. However, instead of clicking the Add button, click the little
drop-down arrow on the right edge of the button and select "Add As Link".
The source file will be added to your project but will remain in its
existing location.

Personally I wouldn't do this, I'd go with the DLL solution as others have
suggested. But if you really want to do it like this then this may be
suitable for your needs.

HTH,
 

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