Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-06-16
3
Medium Priority
?
212 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 400 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 1600 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
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…
Suggested Courses

705 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