Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help: receive some data from other form

Status
Not open for further replies.

nicholasting

Programmer
Jul 28, 2006
15
MY
i'm am vb6 programmer, is a beginner of vb2008. i faced some difficulties that not exists in vb6. please help:-

i have 2 forms: Form A and Form B

Form A call Form B. in Form B, once i close Form B, i will need to pass some data from form B back to Form A without refresh my Form A.

in vb6, i can write as in FormB

private sub cmdOK_Click()
FormA.Text1 = FormB.Text1
FormA.Text2 = FormB.Text2
FormA.Text3 = FormB.Text3

Me.Close
end sub

in vb2008 i cant write like this if i using the method
Dim objFormA = new FormA
however, if i use the method as like VB6,
FormB.show vbModal
i encountered FormB will hold the memory. everytime i called the FormB it will show whatever i was key in previously unless i quit the application.

any idea guys?

regards,
nic
 

How about this:

Form1: 3 text boxes, 1 button
Form2: 3 text boxes, 1 button
Code:
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Button1.Click
[blue]        Dim frm As New Form2
        frm.ShowDialog()[/blue]
    End Sub
End Class
Code:
Public Class Form2
    Private Sub Button1_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles Button1.Click
[blue]        With Form1
            .TextBox1.Text = TextBox1.Text
            .TextBox2.Text = TextBox2.Text
            .TextBox3.Text = TextBox3.Text
        End With
        Me.Dispose()[/blue]
    End Sub
End Class

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top