Pass date between form1

  • Thread starter Thread starter Hugh
  • Start date Start date
H

Hugh

Hi,

I want to pass the text in the texbox on one form to the
textbox on another form. I thought it is very basic.
However, I can not do it right. It works for some
textboxes on the form but not all. What I find is that it
works if the text in the textboxes on the form1 were
entered during designing stage. It does not work if the
text is updated during program run time.

Here is my sample code:

Sub GetValueFromAnotherForm()
Dim frm1 as New Form1
me.textbox1.text = frm1.textbox1.text
me.textbox2.text = frm1.textbox2.text
End sub

The program starts with Form1 and Form2 is child form.

Thanks in advance.
 
Hi ,
In your code, you have not shown the form using Frm.show. Also you
should create the frm variable just once and then use it to get the values.
Example you should declare the frm variable at the form level. Then you can
show the frm in a button click like

public sub showform()
frm = new form2

end sub


public sub GetValue()

ms.textbox1.text = frm.textbox1.text

end sub

If you do the above, you should get the correct value each time.




Anand Balasubramanian
Microsoft, Visual Basic .NET

This posting is provided "AS IS" with no warranties, and confers no rights.
Please reply to newsgroups only. Thanks
 
Back
Top