Greetings,

If i as for example have this:

This is my main window

Class MainWindow 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Dim Other As New Window1
        Other.Show()
    End Sub
End Class

This is the window that opens when button is clicked

Public Class Window1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Dim Main As New MainWindow
        Main.TextBox1.Text = TextBox1.Text
    End Sub
End Class

So what i want it to do is that the textbox1.text in the MainWindow, loads the "Value" from Textbox1.text in the Window1

Edited 4 Years Ago by fRodzet

Hmmm, seems like your using VB2008/10.

Well, heres an idea:

AnotherWindow.Textbox1.Text = MainWindow.Textbox1.Text

Or you can use With, say:

With AnotherWindow
    .Textbox1.Text = MainWindow.Textbox1.Text
End With

Is this?

Class MainWindow 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Dim Other As New Window1(TextBox1)
        Other.Show()
    End Sub
End Class

Public Class Window1
   Private DestTB As TextBox
   Public Sub New(ByVal DestTB As TextBox)
      InitializeComponent()
      Me.DestTB = sourceTB
   End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
        Me.DestTB.Text = TextBox1.Text
    End Sub
End Class

Edited 4 Years Ago by TnTinMN: typos

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        With Form2
            .txtform2.Text = txtform1.Text
            .Show()
        End With

    End Sub
End Class
This article has been dead for over six months. Start a new discussion instead.