i have two forms in my program. The second form appears when button1 is clicked. I would like the information (textboxes) to be filled in when the second form loads. basically i have a complex calculator and when button 1 is clicked i want a second form to show with multiple answers populated into textboxes. any ideas?

Recommended Answers

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        With Form2
            .TextBox1.Text = TextBox1.Text
            .Show()
        End With
    End Sub
End Class
Jump to Post

All 3 Replies

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        With Form2
            .TextBox1.Text = TextBox1.Text
            .Show()
        End With
    End Sub
End Class

You can also do:

Public Class Form1
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Form2.Show()
        Form2.TextBox1.Text = Me.TextBox1.Text 'Where Me references Form1 - the TextBox1 from Form1
    End Sub
End Class

thank you

Be a part of the DaniWeb community

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