Multiple Forms Interactions....

pad

Member
Joined
Jan 18, 2005
Messages
14
Programming Experience
5-10
Hi...

First I've to load Form1. Then from Form1 i've to load Form2. From Form1 i've to pass some values to Form2. Form1 should not be closed in that time.

Then i've to do some operations in Form2. Then Form2 closed. While Form2 closed i've to send few values from Form2 to Form1.

How to do it in a simple and efficient way. Help me...

Thanks in advance...
 

mzim

Well-known member
Joined
Jun 3, 2004
Messages
187
Location
Other side of the rock
Programming Experience
1-3
this is the simple way...but dunno if this would be the efficient one.

VB.NET:
'in the form1 button click event pass a value to the textbox in form 2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim f As New Form2()
		f.TextBox1.Text = "jump and die"
		f.ShowDialog()
		Me.TextBox1.Text = f.ComboBox1.Text
	End Sub

'do some stuff in your form2 and the value from your combobox in form2 will pass to the textbox in the form1
'in your form2 button click event to close your form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Me.Close()
	End Sub
 

cjaymcmeans

Well-known member
Joined
Jan 12, 2005
Messages
85
Programming Experience
3-5
if you need something form form1 and pass it to form2...
you have to options depending on what is it that you need to do..

1. declare a public variable and pass it on as you go through forms...

2. is make a public procedure or sub that will process it...

do this before you close the form...
 
Top Bottom