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

Recommended Answers

All 4 Replies

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?

Can't seem to get it work.. nothing seems to happen

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
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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.