passing data between forms

shiznish

New member
Joined
Jul 27, 2007
Messages
2
Programming Experience
Beginner
hi
i'm a beginer in vb.net.....
i'm develpoing a simple application....i have a doubt regarding passing values between forms......its like
there is one main form ,form1 which contains two textboxes and two buttons ,when button 1 is clicked form2 be loaded.it contains a textbox and a button ,.on clicking this button this form should close and value from textbox should be written in form1 which is already opend....
similarly for button2 on form1 clickd,form3 opend ...and on clicking a button in form3 ,close form3 and pass a value to already opend form1....

pls anybody help....
 
This code would be in Form1:
VB.NET:
Dim f2 As New Form2

f2.TextBox1.Text = "initial value"

If f2.ShowDialog() = Windows.Forms.DialogResult.OK Then
    MessageBox.Show("Final value: " & f2.TextBox1.Text)
End If

f2.Dispose()
 
thanks for ur reply
but this only cleard one part ,
I want a value from form2 textbox to appear in already opend form1.
 
I already showed you how to get the value from Form2:
VB.NET:
MessageBox.Show("Final value: " & f2.TextBox1.Text)
If you want to display the string in a TextBox instead of a MessageBox then do so. Don't assume that examples will provide a ready-made solution. Examples are intended to illustrate a principle. It's then up tp you to apply that principle to your own set of circumstances. You have code to get the desired string from the dialogue. I'm sure you know how to display a string in a TextBox.
 
Back
Top