lets say I have 2 forms, Form1 and Form2
how do I call certain values that user inputted in text box from Form1 to appear on Form2?
and also, i've been trying to figure out how to have 2 forms, but when the user is on form1, when button is clicked, the user advances to form2 but still in the same window, no additional windows are to be open.

:rolleyes:

First double click on the "MyProject" under "Solution Explorer". Toward the bottom left you should find "Shutdown Mode". CHange this to "When last form closes".
To transfer text and open form2:

'In the TextChanged event transfer the characters to form 2 textbox.
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Form2.TextBox1.Text = TextBox1.Text
    End Sub

    'Here is where you want to be carefull. If you close form1 before you open form2 then the program ends.
    'If when you come back to form1 you want your textbox to remain the same then do not close it but
    'hide it..... Me.Hide.
    'If you are making changes to the textbox in form2 and returning it to form1 textbox then do same
    'in the TextChanged on form2 as above on form1.    
   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()
        Me.Close()
    End Sub

To return to form1:

'Make sure you open form1 before closing form2 or the porgram will end.    
     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Show()
        Me.Close()
    End Sub

Hope this is what you needed.

You learn more here by accident, than other places by design.

Translation: I wasn't looking for that info, but am glad I found it!

the code doesnt work
maybe i didnt explain it properly. let me give you an example
When user starts my program, Form1, the user will have to type in their name, after user types it in and clicks a button to advance, on the Form2, it will say, "Hi, ????" what the name was.
how do i do that???

The first part is the same. On form2 create a variable called something like MyName as a string. In your TextChanged of form1 change the code to read "Form2.MyName = TextBox1.Text". In form2.load if you have a textbox to show the greeting then do something like this:
TextBox1.Text = "Hi " & MyName

That was about as clear as mud, so let's try again.
On form1 put a textbox and a button with this code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()
        Me.Close()
    End Sub

    Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Form2.MyName = TextBox1.Text
    End Sub

On form2 place a label and this code.

Public MyName As String

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        label1.Text = "Hi " & MyName & "!"
    End Sub

Make sure you change the "Shutdown mode" to "When last form closes".
Hope this helps.

Hi ,

Try following code snippnet -

1. Form 2 create two public properties. suppose i.name ii. address
2. Form1 on button click - create form2 object objform2.
set objform2.name= value

Hi ,
I can do that project . Give me the spceification and cost estimation.

Thanks & Regards,
Siddharth Shembade
+919890396166:confused:

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