transfering info between forms in Visual Basic

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can i transfer information that user inputs from a textbox in one form to
a label in a second form?
 
Hi,

When is the second form created? If it's created by the first form in
response to a button click then you probably want something like this:

private void Button1_click(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.XXX(textBox1.Text);
form2.Show();
}

and in Form2

public void XXX(string data)
{
label1.Text = data;
}

Substituting XXX for an appropriate method name. You could also make it a
property, it's up to you. Sorry for the C#, I'm not familiar enough with VB
to be able to write it outside of the IDE.

Hope this helps.

Regards,
Matt Garven
 
Back
Top