VB.Net - Imports vs References

Excellent explanation!

Thank you very much!



Thanks,

Joe Rojas

IT Manager

TNCO, Inc.

781-447-6661 x7506

jrojas@...



________________________________

From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of Adam Tuliper
Sent: Saturday, March 03, 2007 4:19 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Re:VB.Net - Imports vs References



References: Required before you can use an import - tells the compiler
to
include the specified library in the compile.

Imports: Tells the compiler where to look inside your references
(referenced assemblies) to find "SomeObject" - when you say Imports
Something.Something - these are namespaces - and the imports stmt says
"include this namespace in my search".

For instance, I created my own class called "TextBox", Microsoft has one
of
course. So which one to use when Im writing code?

The compiler will look through your "Imports" to find a TextBox class.
If it
finds multiple, you will get an error. Its quite possible after a while
of
developing you will create a class that has the same name as something
else
in the framework, namespaces will separate your object from the other
developers.

In the case of epicor, to use an object - you need to add your reference
to
Epicor.Mfg.BO.JobPart..etc" and then when you say:

Dim jobAdapt As JobPartAdapter

The compile will look at your "Imports" namespaces and find this object.
If
you have included a reference and don't use "imports" and try to write a
line of code to use it.. it won't be able to find it and you will get an
error. Now, you technically don't need an import. If you want to name
all
your objects with a full name, for ex. You include a reference to some
epicor library containing some class you want to use, you can specify
its
full name:

Dim Dim jobAdapt As Epicor.Mfg.Adapters.JobPartAdapter

In that case you don't need the imports statement because you are
specifying
the full path where that object is found - but its easier to code this
way..

[Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]
Hello,



Still learning VB.Net.



I have a question. What is the difference between using the Imports
statement and adding a Custom Reference when trying to add additional
components to your code?



When working with customizations for Vantage, adding an "Imports
Epicor.Mfg.AD.PO" did not allow me to use the POAdapter but when I added
Epicor.Mfg.AD.PO as a custom reference I could.

In fact, when using the Imports example, it genereated an error about
not being to find the namespace or something like that.

I'm just trying to wrap my mind around why.



Thanks,

Joe Rojas

IT Manager

TNCO, Inc.

781-447-6661 x7506

jrojas@...



[Non-text portions of this message have been removed]
References: Required before you can use an import - tells the compiler to
include the specified library in the compile.



Imports: Tells the compiler where to look inside your references
(referenced assemblies) to find "SomeObject" - when you say Imports
Something.Something - these are namespaces - and the imports stmt says
"include this namespace in my search".

For instance, I created my own class called "TextBox", Microsoft has one of
course. So which one to use when Im writing code?



The compiler will look through your "Imports" to find a TextBox class. If it
finds multiple, you will get an error. Its quite possible after a while of
developing you will create a class that has the same name as something else
in the framework, namespaces will separate your object from the other
developers.



In the case of epicor, to use an object - you need to add your reference to
Epicor.Mfg.BO.JobPart..etc" and then when you say:

Dim jobAdapt As JobPartAdapter

The compile will look at your "Imports" namespaces and find this object. If
you have included a reference and don't use "imports" and try to write a
line of code to use it.. it won't be able to find it and you will get an
error. Now, you technically don't need an import. If you want to name all
your objects with a full name, for ex. You include a reference to some
epicor library containing some class you want to use, you can specify its
full name:

Dim Dim jobAdapt As Epicor.Mfg.Adapters.JobPartAdapter

In that case you don't need the imports statement because you are specifying
the full path where that object is found - but its easier to code this way..









[Non-text portions of this message have been removed]