By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,575 Members | 1,395 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,575 IT Pros & Developers. It's quick & easy.

use Namespace to reference a form in a Module?

P: n/a
Ron
Hello,

I have added a Namespace to my vb.net project. The
namespace is the name of the project. Then I start the
project from Sub Main

Module1
Sub Main()
Application.Run(New MyProj.Form1)
End Sub
End Module

In a separate module, Module2, I want to reference Form1
so that I can write some data to a textbox, txtData. I
imported the Namespace MyProj to Module2.

Imports MyProj
Imports ... (everything else)

I tried referencing Form1 like this: MyProj.Form1... but
I could not see txtData in a dropdown after Form1. I know
that I could convert Module2 to a Class Module as pass in
txtData to the procedure in the Class Module. But is it
possible to reference Form1 (or really - txtData) in
Module2 as a standard module? Could I do this with the
Namespace?

Thanks,
Ron


Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Ron" <an*******@discussions.microsoft.com> schrieb:
I tried referencing Form1 like this: MyProj.Form1... but
I could not see txtData in a dropdown after Form1. I know
that I could convert Module2 to a Class Module as pass in
txtData to the procedure in the Class Module. But is it
possible to reference Form1 (or really - txtData) in
Module2 as a standard module? Could I do this with the
Namespace?


You cannot do that using namespaces, that's something different. Namespaces
are used to structure your classes, like directories (a.k.a. folders) in the
file system.

What you want to do is accessing members of an /instance/ of a form from
within a module. You will have to make a reference to your instance of the
form available to the module. There are different ways to do that:

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #2

P: n/a
"Ron" <an*******@discussions.microsoft.com> schrieb:
I tried referencing Form1 like this: MyProj.Form1... but
I could not see txtData in a dropdown after Form1. I know
that I could convert Module2 to a Class Module as pass in
txtData to the procedure in the Class Module. But is it
possible to reference Form1 (or really - txtData) in
Module2 as a standard module? Could I do this with the
Namespace?


You cannot do that using namespaces, that's something different. Namespaces
are used to structure your classes, like directories (a.k.a. folders) in the
file system.

What you want to do is accessing members of an /instance/ of a form from
within a module. You will have to make a reference to your instance of the
form available to the module. There are different ways to do that:

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #3

P: n/a
Ron
Thank you very much. That worked perfectly!

Ron

-----Original Message-----
"Ron" <an*******@discussions.microsoft.com> schrieb:
I tried referencing Form1 like this: MyProj.Form1... but I could not see txtData in a dropdown after Form1. I know that I could convert Module2 to a Class Module as pass in txtData to the procedure in the Class Module. But is it
possible to reference Form1 (or really - txtData) in
Module2 as a standard module? Could I do this with the
Namespace?
You cannot do that using namespaces, that's something

different. Namespacesare used to structure your classes, like directories (a.k.a. folders) in thefile system.

What you want to do is accessing members of an /instance/ of a form fromwithin a module. You will have to make a reference to your instance of theform available to the module. There are different ways to do that:
Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/? id=accessmainform&lang=en>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

.

Nov 21 '05 #4

P: n/a
Ron
Thank you very much. That worked perfectly!

Ron

-----Original Message-----
"Ron" <an*******@discussions.microsoft.com> schrieb:
I tried referencing Form1 like this: MyProj.Form1... but I could not see txtData in a dropdown after Form1. I know that I could convert Module2 to a Class Module as pass in txtData to the procedure in the Class Module. But is it
possible to reference Form1 (or really - txtData) in
Module2 as a standard module? Could I do this with the
Namespace?
You cannot do that using namespaces, that's something

different. Namespacesare used to structure your classes, like directories (a.k.a. folders) in thefile system.

What you want to do is accessing members of an /instance/ of a form fromwithin a module. You will have to make a reference to your instance of theform available to the module. There are different ways to do that:
Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/? id=accessmainform&lang=en>
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

.

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.