Solved

How do I use values from objects on Form A with objects on Form B?

Posted on 2006-06-16
3
206 Views
Last Modified: 2010-04-23
I have a Form, say Form A with many objects(textboxes, grids, menus, etc). A menu item from Form A calls Form B. I need to have Form B know about, say, a textbox text from Form A AND I need to have Form A know about, say, a variable value from form B. In other words, both forms need access to any object from the other form. Do you have some code examples of how to make the two forms share information?  Does this interest anyone? Thank you for your assistance.
0
Comment
Question by:IT_Steve
3 Comments
 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 100 total points
ID: 16922375
on formA put the following code:

Public f2 As FormB

then do the following
        Dim tb As TextBox
        tb = f2.TextBox1()
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 400 total points
ID: 16922542
Do something like...

Public Class FormA
    ...

    Private frmB As FormB

    Private Sub Button1_Click(...)
        frmB = New FormB
        frmB.frmA = Me
        frmB.Show()
    End Sub

    Private Sub Foo()
        If Not (frmB Is Nothing) Then
            frmB.TextBox1.Text = "Hello from FormA"
        End If
    End Sub

End Class

Public Class FormB
    ...

    Public frmA As FormA

    Private Sub Foo()
        If Not (frmA Is Nothing) Then
            frmA.TextBox1.Text = "Hello from FormB"
        End If
    End Sub

End Class
0
 

Author Comment

by:IT_Steve
ID: 16923201
YZlat's solution  was interesting in that I learned how to assign a textbox to a new textbox. But Idle_Mind's solution pretty much does what I was looking for. I will split the points because I can use both solutions in my application. Thank you for your expertise.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now