How to see data from form1 in module1

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

I'm trying to make my app source easier to read & follow by breaking up
the code into modules. One module has the fileIO routines, another
module has the sockets routines, etc. However, I can't see any of the
data from the main form.

I need to send data entered into a textbox from form1 to a remote server
via a routine in the sockets module. However, I can't see the textbox
from the module.

This is probably really simple, and i'm probably still thinking in VB6
terms.

Thanks!
 
Hi,


Pass a reference to form1 when you call the procedures in the
module.


Module Test

Public Sub ShowText(ByVal frm As Form1)

MessageBox.Show(frm.TextBox1.Text)

End Sub

End Module



To use.

ShowText(Me)



Ken
--------------------
I'm trying to make my app source easier to read & follow by breaking up
the code into modules. One module has the fileIO routines, another
module has the sockets routines, etc. However, I can't see any of the
data from the main form.

I need to send data entered into a textbox from form1 to a remote server
via a routine in the sockets module. However, I can't see the textbox
from the module.

This is probably really simple, and i'm probably still thinking in VB6
terms.

Thanks!
 
I'm trying to make my app source easier to read & follow by breaking up
the code into modules. One module has the fileIO routines, another
module has the sockets routines, etc. However, I can't see any of the
data from the main form.

I need to send data entered into a textbox from form1 to a remote server
via a routine in the sockets module. However, I can't see the textbox
from the module.

There are various options. You could declare the text box Friend instead of
Private in the don't-touch-this-or-we'll-break-your-fingers "Windows Form
Designer generated code" region. Be aware that this could get reset by the
designer.

A more elegant solution, besides passing the form reference as Ken
suggested, would be to create a property in Form1 that returns the value of
the text box.
 
You dont have to change it within the designer code, there is an access
modifiers property for the textbox control, this is set to default as
Friend

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .

Time flies when you don't know what you're doing
 
The tricks of visual inheritence are started to fall together...

Learn something everyday.

Thanks Terry!
Greg
 
You dont have to change it within the designer code, there is an access
modifiers property for the textbox control, this is set to default as
Friend

Oh, yeah. I've seen that. Apparently it didn't sink in....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top