Home All Groups Group Topic Archive Search About

can I use Imports with a VB2005 class namespace?

Author
22 Aug 2006 6:48 PM
Rich
Hello,

I have a project (vb2005) and I added a class (a vb file) that resides in a
separate directory from the main project.  Rather than instantiating objects
from this class to use its properties and methods, is it possible to use the
Imports keyword like in C# to import that class namespace?

How can this be done?  or how can something equivalnet be done?

Thanks,
Rich

Author
22 Aug 2006 7:01 PM
Herfried K. Wagner [MVP]
"Rich" <R***@discussions.microsoft.com> schrieb:
> I have a project (vb2005) and I added a class (a vb file) that resides in
> a
> separate directory from the main project.  Rather than instantiating
> objects
> from this class to use its properties and methods, is it possible to use
> the
> Imports keyword like in C# to import that class namespace?

You can assign a namespace to the file using the 'Namespace' block.  Then
you can import the namespace and instantiate/use the class.  In addition you
can even import the class in order to be able to access its shared members
without qualification by the class name.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
22 Aug 2006 7:08 PM
Rich
I think I figured this out.  I gieve the added class a namespace name
(without including the project name as part of the namespace unlike C#). 
Then when I type Imports in the main class I will see the project name in the
initial listing, I select the project name, then I see the class(es) I add to
the project.

Show quoteHide quote
"Rich" wrote:

> Hello,
>
> I have a project (vb2005) and I added a class (a vb file) that resides in a
> separate directory from the main project.  Rather than instantiating objects
> from this class to use its properties and methods, is it possible to use the
> Imports keyword like in C# to import that class namespace?
>
> How can this be done?  or how can something equivalnet be done?
>
> Thanks,
> Rich
Author
23 Aug 2006 5:44 AM
Cor Ligthert [MVP]
Rich,

Did you look at the answer from Herfried, seems for me quiet the same.
The times of sending are equal, but I get the idea because that there is no
reply on Herfried answer that you did not even look at that. Knowing that
set you on a lower answering priority.

Cor

Show quoteHide quote
"Rich" <R***@discussions.microsoft.com> schreef in bericht
news:8566ED0D-115D-49B3-9149-9EE8311BE22F@microsoft.com...
>I think I figured this out.  I gieve the added class a namespace name
> (without including the project name as part of the namespace unlike C#).
> Then when I type Imports in the main class I will see the project name in
> the
> initial listing, I select the project name, then I see the class(es) I add
> to
> the project.
>
> "Rich" wrote:
>
>> Hello,
>>
>> I have a project (vb2005) and I added a class (a vb file) that resides in
>> a
>> separate directory from the main project.  Rather than instantiating
>> objects
>> from this class to use its properties and methods, is it possible to use
>> the
>> Imports keyword like in C# to import that class namespace?
>>
>> How can this be done?  or how can something equivalnet be done?
>>
>> Thanks,
>> Rich