0

How do i get data from 1 form to another.

example:

in form 1 when user enters something in inputbox("") send the data to form 2/and display it in.

Sub form1()
  InputBox("Enter something " & Num, "Read Names")
  form2.show
end sub
iks lake
  • 15
  • 1
  • 6

1 Answers1

2

There are many ways you could do this, for example create an instance of form2, and set the property of one of its controls before you show it. If form2 has a label control called Label1:

    Dim userName As String = InputBox("Whats your name?")

    Dim infoForm As New Form2
    infoForm.Label1.Text = userName
    infoForm.ShowDialog()

As per your comment, you can add the string to the listbox the same way you set the lable:

    Dim userName As String = InputBox("Whats your name?")

    Dim infoForm As New Form2
    infoForm.lstItinerary.Items.Add(usersName)
    infoForm.ShowDialog()    
Steve
  • 20,703
  • 5
  • 41
  • 67
  • Yes, but how do i display the userName in form2 ?, i added this in form2: Dim userName As String lstItinerary.Items.Add(userName) – iks lake Dec 06 '12 at 14:26
  • Well in my example you have Label1 in form2. I will edit my answer as per your comment – Steve Dec 06 '12 at 14:29
  • @user57432 can you please help me here: http://stackoverflow.com/questions/13782411/vb-net-if-inputbox-is-greater/13782562 – iks lake Dec 09 '12 at 17:20