Solved

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

Posted on 2006-06-16
3
205 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

10 Experts available now in Live!

Get 1:1 Help Now