Solved

passing information between forms?

Posted on 2004-09-24
6
186 Views
Last Modified: 2010-08-05
how do i do this?
0
Comment
Question by:stromberg10
6 Comments
 
LVL 1

Expert Comment

by:nikelsh
ID: 12141646
use property get and set .... in form.
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12141760
create property with public prefix and do not free the form immidiatly then you can get the information like form.textbox1.text
0
 
LVL 2

Expert Comment

by:ahmadfuwad
ID: 12141806
by using form objects
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 28

Expert Comment

by:iboutchkine
ID: 12142064
'Create a module CT.vb
'Create one shared property for each form
'This example has two forms(Form1 and From2)
Public Class CT
    'For cross talking between forms
    Private Shared m_From1 As From1
    Public Shared Property From1() As From1
        Get
            Return m_From1
        End Get
        Set(ByVal Value As From1)
            m_From1 = Value
        End Set
    End Property
    Private Shared m_Form2 As Form2
    Public Shared Property Form2() As Form2
        Get
            Return m_Form2
        End Get
        Set(ByVal Value As Form2)
            m_Form2 = Value
        End Set
    End Property
End Class

'To call Form2 from Form1
Dim myForm2 as new Form2

'Tell Form2 who to talk back to and open Form2
'You can also put code here to send to a Form2 control
        CT.Form1 = Me
        myForm2.Show()

'You can talk back from Form2 to this instance of Form1
'By putting code in From2 like...
      CT.Form1.Label1.Text = "Blah, Blah"
0
 
LVL 19

Expert Comment

by:Desp
ID: 12142456
This article has all the necessary code with explanation you want
http://www.developerfusion.com/show/4375/9/

0
 
LVL 8

Accepted Solution

by:
wguerram earned 250 total points
ID: 12143304
Declare the forms variable as public in a module:

Public Form1 as new form1
public Form2 as new form2

in your sub main

form1.Show

'From inside the form1

Form2.Show


Now from Form2 you can access Form1 via the public variable:

MsgBox Form1.txtName.Text

'--------------------

In order to access controls from both forms you have to change its Modifiers property to Public.

You can add public variables to the forms and also will be accessible, like:

Public MyVar as string.

'Example

Public Module1
        Public Form1 as new Form1
        Public Form2 as new Form2
End

Public Class Form1
     Public MyVar as string

End class

Public Class Form1
     Public MyVar2 as string

End class
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

24 Experts available now in Live!

Get 1:1 Help Now