Link to home
Start Free TrialLog in
Avatar of Matrix1000
Matrix1000

asked on

Passing textbox data between forms - whats wrong with this simple code?

I'm trying to get textbox contents from form CaseNumber to the main form, Form1
It always seems that 'passedtext' is always blank or ""

Whats wrong with my code?
Form2 Code (form name CaseNumber):
 
Private Sub NewCase_Click(ByVal sender As System.Object, ByVal e As 
System.EventArgs) Handles NewCase.Click
        Dim PassedText As String
        PassedText = txtCaseNumber.Text.ToString
        Form1.NewWindow()
        Me.Close()
 
    End Sub
 
--------------------------------------------------
Form1 code:
 
 Private _passedText As String
 
    Public Property [PassedText]() As String
        Get
            Return _passedText
        End Get
        Set(ByVal Value As String)
            _passedText = Value
        End Set
 
    End Property
 
Public Sub NewWindow()
        'Protected Sub MDIChildNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
        Dim NewMDIChild As New MainChildForm()
 
        'Set the Parent Form of the Child window.
        NewMDIChild.MdiParent = Me
 
        'Set the name of the new Child Window
        NewMDIChild.Text = PassedText 
 
        'Display the new form.
        NewMDIChild.Show()
 
        MessageBox.Show(PassedText)
     End Sub
 
 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ee_rlee
ee_rlee
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial