how to get a textbox.text from another form?

ssfftt

Well-known member
Joined
Oct 27, 2005
Messages
163
Programming Experience
1-3
[solved]how to get a value of textbox.text from another form?

I have 2 forms, one is frmLogin, one is frmRetrievePW.on frmLogin, i have "txtUsername.text" which enables user to input a user name. When i click on a button, it frmRetrievePW opens up.while the frmRetrievePW opens, I want to pass the input value of "txtUsername.text" from frmLogin to frmRetrievePW and display it into txtRetrievePW.text.I tried this in frmRetrievePW onLoad event to test whether it's working, however, it didnt work. can anyone help out plz?
VB.NET:
        Dim frmLogin As New frmLogin        txtRetrievePW.text = frmLogin.txtUsername.text        MessageBox.Show(frmLogin.txtLoginName.Text) 'just for testing
 
Last edited:
wierd! I made some change.on frmLogin button click event, i have code
VB.NET:
frmPWReminder.lblName.Text = txtLoginName.Text.Trim
on frmRetrievePW on load event, i have:
VB.NET:
MessageBox.Show(lblName.Text)
at runtime the message shows nothing (a null value), but actually the value is passed to frmRetrievePW and displayed in lblName.Text.why is that?>
 
if both forms are in same project then the easy way out is to declaring a variable at global level (above & out of both form classes) & save value of 1st form textfield to variable. When u load the 2nd form from the 1st, then retrive the value from the same variable in second form.
 
Back
Top