Solved

passing information between forms?

Posted on 2004-09-24
6
189 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 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.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

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 …
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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