User interface

  • Thread starter Thread starter ChrisB
  • Start date Start date
C

ChrisB

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?
 
ChrisB said:
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.
 
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.
 
Back
Top