Solved

passing information between forms?

Posted on 2004-09-24
6
190 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Technology Partners: 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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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