How would I code a program to take information entered in a text box on
a form and use it or a pointer to use the information in a different
part of the program?
Herfried K. Wagner [MVP] - 11 Feb 2005 19:52 GMT
"ChrisB" <ChrisB@spam.net> schrieb:
> How would I code a program to take information entered in a text box on a
> form and use it or a pointer to use the information in a different part of
> the program?
Simple solution:
\\\
Friend Module Data
Public UserName As String
...
End Module
.
.
.
Data.UserName = Me.UserNameTextBox.Text
.
.
.
MsgBox(Data.UserName)
///
Alternatively you can use the Singleton design pattern to implement
something similar to that shown above. If your forms' instances are always
kept alive, you can pass references to the forms containing the data around
in order to be able to access the data stored by the form.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Tim Wilson - 11 Feb 2005 20:21 GMT
If I'm understanding the question correctly, I guess it comes down to how
the information is to be shared with the rest of the application. There are
at least two options. One is to create a custom event and another is to
create a custom property on the Form. If another Form needs to be notified,
information "push", when something has happened then you would use an event,
if another Form is going to "pull" the information out then a property would
be best. So if the whole idea is to allow a user to enter information into a
TextBox and then have this information exposed on another Form, then look
into a property. Or, if the information is vital to the data on the other
Form, then you might even want to create a constructor (sub New in VB) that
requires this information.

Signature
Tim Wilson
.Net Compact Framework MVP
> How would I code a program to take information entered in a text box on
> a form and use it or a pointer to use the information in a different
> part of the program?