473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

use Namespace to reference a form in a Module?

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
4 1589
"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
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

88
by: Tim Tyler | last post by:
PHP puts most of its functions into a big flat global namespace. That leads to short function names - but creates a namespace minefield for programmers. Lots of the functions are legacies from...
5
by: Blair Hall | last post by:
Can anyone please tell me how to correctly use a built in function when there is a function of the same name in local scope? Here is an example. Suppose the following is in myApply.py: def...
7
by: Doug Rosser | last post by:
I'm writing a fairly complicated test framework and keeping configuration data inside ini files that are parsed at runtime by the ConfigParser module. For example, there would be a section...
6
by: Carlos | last post by:
Hi all, I am trying to access a public field of another form class within the same namespace. The field is public, what is the best way to access it from a different class? I defined as private...
9
by: Buz Waitz | last post by:
I'm a newbie. I've created a datalayer class which I creatively called sqlAccess and placed in a namespace I just as creatively called MyDomain.DataAccessLayer. (Well now, I didn't actually use...
0
by: Ron | last post by:
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)...
3
by: dotNETnews | last post by:
Little confused... When I declare a namespace variable in module I can use it anywhere in the project. That's clear. I read a book in which the author said that namespace variables can be...
1
by: Tom Edelbrok | last post by:
I'm upgrading from VB6 to VS.Net Pro 2003, and am trying to plan a way of using NAMESPACE's. Under VB6 we had a variety of global procedures stored in a series of modules, as well as in classes....
4
by: | last post by:
When I add a new module in the project explorer pane, the wizard inserts a Module1 scope, so any variables I will put there can be accessed with a qulification, e.g. dim a as integer will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.