473,785 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing "Forms" objects from a module

All,

(here's an easy one)...

This is probably a stupid question - please bare with me as I am new to
dotNet.

How does one reference objects on a form from a module? In 6.0 you could
simply provide the form name as a prefix to the object within the form and
that would do it (kind of like providing a fully qualified path name to a
file).

What is the mechanism for such a reference from a VB.net module?

Thanks in advance for any insight

-Paul
Jan 13 '06 #1
17 18432
your can easily find answer, in the following code

------------------------------------------------------------------------

Module Module1

Function A_Function()
MessageBox.Show (" i m in module1")
End Function

End Module

------------------------------------------------------------------------

Public Class Form1
Inherits System.Windows. Forms.Form

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Module1.A_Funct ion()

End Sub
End Class
------------------------------------------------------------------------

Jan 13 '06 #2
Almost.

The code snipit you provided shows the reverse.

You are referncing a module function from a form. I want to reference a form
object from a module. I have tried the 6.0 syntax which I described in my
original post - it's pretty much the same as the "form-to-module" reference
that you have illustrated.

How does one reference a form object from within a module?
"Debugger81 " <so**********@g mail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
your can easily find answer, in the following code

------------------------------------------------------------------------

Module Module1

Function A_Function()
MessageBox.Show (" i m in module1")
End Function

End Module

------------------------------------------------------------------------

Public Class Form1
Inherits System.Windows. Forms.Form

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Module1.A_Funct ion()

End Sub
End Class
------------------------------------------------------------------------

Jan 13 '06 #3
"Paul Helmuth" <ph******@cvit. com> schrieb
All,

(here's an easy one)...

This is probably a stupid question - please bare with me as I am new
to dotNet.

How does one reference objects on a form from a module? In 6.0 you
could simply provide the form name as a prefix to the object within
the form and that would do it (kind of like providing a fully
qualified path name to a file).

What is the mechanism for such a reference from a VB.net module?

Thanks in advance for any insight

If possible, don't use a Module. See previous discussions in this group.

Why don't you put the code in the Form?
Armin
Jan 13 '06 #4
"Armin Zingler" <az*******@free net.de> schrieb:
If possible, don't use a Module. See previous discussions in this group.


That's just your personal opinion.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Jan 13 '06 #5
Paul you can do it by making the instance of the form in module like
shown below:
Module Module1

Function A_Function()

Dim frmInstance As Form1
frmInstance = New Form1

frmInstance.cal lMeFunction81()

End Function

End Module

* callMeFunction8 1() will be called which is in the form, Or you can do
what ever you want to do with it, as you got the instance of that form.
Paul Helmuth wrote:
Almost.

The code snipit you provided shows the reverse.

You are referncing a module function from a form. I want to reference a form
object from a module. I have tried the 6.0 syntax which I described in my
original post - it's pretty much the same as the "form-to-module" reference
that you have illustrated.

How does one reference a form object from within a module?
"Debugger81 " <so**********@g mail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
your can easily find answer, in the following code

------------------------------------------------------------------------

Module Module1

Function A_Function()
MessageBox.Show (" i m in module1")
End Function

End Module

------------------------------------------------------------------------

Public Class Form1
Inherits System.Windows. Forms.Form

Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Module1.A_Funct ion()

End Sub
End Class
------------------------------------------------------------------------


Jan 13 '06 #6
Paul,

You could pass a reference to the form to the code in the module.

Kerry Moorman
"Paul Helmuth" wrote:
All,

(here's an easy one)...

This is probably a stupid question - please bare with me as I am new to
dotNet.

How does one reference objects on a form from a module? In 6.0 you could
simply provide the form name as a prefix to the object within the form and
that would do it (kind of like providing a fully qualified path name to a
file).

What is the mechanism for such a reference from a VB.net module?

Thanks in advance for any insight

-Paul

Jan 13 '06 #7
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schrieb
"Armin Zingler" <az*******@free net.de> schrieb:
If possible, don't use a Module. See previous discussions in this
group.


That's just your personal opinion.


Whom else's opinion should I post? It's not only an opinion but also a
suggestion.
Armin

Jan 13 '06 #8
When you say "objects ON a form", do you mean controls? If not, please
ignore this post. If so, though...

I would do this as a property of the form, exposing the object. This gives
your form control over itself, provides true encapsulation, and allows you
the ability to reject requests for the object, etc., etc. Directly
referencing the control is, IMHO, not the best programming practice for
these reasons.

In the form:

Public ReadOnly Property NameTextBox() As TextBox
Get
NameTextBox = TextBox1
End Get
End Property
In the module:

Dim mForm1 As Form1

Sub Test()
MsgBox(mForm1.N ameTextBox.Text ())
End Sub

Where NameTextBox is a descriptive name of your text box object, and mForm1
is an object that references your form.

One last thing... I have no idea what your application is, and I don't mean
to preach at all, but you may want to take the encapsulation concept one
step further and expose only values from your control, such as a property
that exposes the text value of a text box.
Jan 13 '06 #9
When you say "objects ON a form", do you mean controls? If not, please
ignore this post. If so, though...

I would do this as a property of the form, exposing the object. This gives
your form control over itself, provides true encapsulation, and allows you
the ability to reject requests for the object, etc., etc. Directly
referencing the control is, IMHO, not the best programming practice for
these reasons.

In the form:

Public ReadOnly Property NameTextBox() As TextBox
Get
NameTextBox = TextBox1
End Get
End Property
In the module:

Dim mForm1 As Form1

Sub Test()
MsgBox(mForm1.N ameTextBox.Text ())
End Sub

Where NameTextBox is a descriptive name of your text box object, and mForm1
is an object that references your form.

One last thing... I have no idea what your application is, and I don't mean
to preach at all, but you may want to take the encapsulation concept one
step further and expose only values from your control, such as a property
that exposes the text value of a text box.
"Paul Helmuth" <ph******@cvit. com> wrote in message
news:T5******** ********@newssv r21.news.prodig y.com...
All,

(here's an easy one)...

This is probably a stupid question - please bare with me as I am new to
dotNet.

How does one reference objects on a form from a module? In 6.0 you could
simply provide the form name as a prefix to the object within the form and
that would do it (kind of like providing a fully qualified path name to a
file).

What is the mechanism for such a reference from a VB.net module?

Thanks in advance for any insight

-Paul

Jan 13 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1638
by: Woody Lemcke | last post by:
Hello all, Would you gurus please share your wisdom on any DB2 equivalents to the Informix "Forms" input form utility and "Ace" report generating utility? The input form will probably be accessed by telneting from a Linux shell or Windows command prompt and used for updating a lab database. Thanks and regards, Woody Lemcke
0
1219
by: gmarquez | last post by:
Hello, I am using "FORMS" authentication, without SSL the behavior is normal, everythings working very well. When in IIS I cheking "Require SSL" (in Secure Communications property), I can't to do login, after introducing the credentials, I am redirected to login's page again, If I take the SSL's Check off in the ISS property, everythings will work very well again. NOTE: I have a valid certificate well installed. What is happening?,...
1
1817
by: Anton ml. Vaheie | last post by:
How do I convince (what I have to set in asp.net server) that my program that is using <authentication mode="Forms" /> can write to, copy, etc. files in directories on local disk? I have given full permisions to local directory (IUSR_Machinename user), but I still get: "System.UnauthorizedAccessException: Access to the path "D:\Inetpub\wwwroot\". Any idea how to change it?
0
5614
by: Angel | last post by:
Hi I have a problem with my web applications. I believe the problem is somehow connected to HttpSession. I use form authentication in my project. Once I authenticate the user and redirect to default page I create an User object and assign this object to session. Then in other forms I access this object and use it to load data from database. Some times I keep data in the object as a property of object. For example let say my object is...
6
1530
by: Alan Silver | last post by:
Hello, I have a page that displays a data list with info from a database. The grid has the usual stuff, edit, update, delete etc. Below this I have a section where they can add a new entry to the list. This has some text boxes for the data, and a button to click when they are ready to submit. To the user, this looks like two separate forms, one containing a grid of existing data and one where they add new data.
1
1429
by: Dib | last post by:
Hi, how do I call a form to open from another form. example I have a frmLogIn and an frmError The frmError have a ListBox. If the frmLogin generated an error I want the error to show in the ListBox on frmError.
1
1824
by: Troy Bull | last post by:
Greetings I am trying to use a singleton to hold a group of forms. I have a MDIMaster form. I have a class called Forms; Forms is a singleton. I want to do something like the following. In MDIMaster (and other forms), I want to get an instance of Forms (the only instance). Inside Forms then there are public variables for each of the possible forms, if a "form" has never been accessed the Forms factory creates a new instance of the...
11
3166
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global" storage is ButtonHasBeenClicked. In this simple example code in Form1 calls a routine in Module1 which then calls code back in Form1 (subroutine WhatEver). WhatEver needs to access ButtonHasBeenClicked but the reference to ButtonHasBeenClicked...
3
7825
by: svdoerga | last post by:
I found a post with the same error here. I'm getting the same error. This code is run in a button click event: ........... DoCmd.OpenForm CurTabViewName, acNormal With Forms(CurTabViewName) ........... At the "With" statement I get the error. Weird thing is this code had been working fine a long time. I've been searching the net and haven't been able to find the solution yet. Does anyone know a solution?
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.