Solved

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

Posted on 2006-06-16
3
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 86

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

627 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