Solved

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

Posted on 2006-06-16
3
207 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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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