Search code examples
vb.netformstextboxvb.net-2010

Transferring text from one form to another form


I'm having a hard time transferring the text from the Textbox4 in StudentInfo form to the Textbox in Categories form. I've done the basic Textbox.Text = Categories.Textbox.Text code (I've reversed it also by coding on Categories_Load event), but still, I can't display the text.

Can anyone help me here?

PS: I've also done the Public Property code. AND by the way, the studentinfo form has still to jump to 2 forms before it reaches the categories form.

My code in a button in studentinfo (confirm & continue)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As     System.EventArgs) Handles Button1.Click
        TextBox4.Text = Categories.yrlvlhere.Text

End Sub

In categories:

Private Sub Categories_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.yrlvlhere.Text = StudentInfo.TextBox4.Text
End Sub

yrlvlhere is the name of the textbox I will be changing texts with.

A visual representation of what I am trying to do:

enter image description here


Solution

  • TextBox4.Text = Categories.yrlvlhere.Text
    

    With this you are overwriting the text from TextBox4 in StudentInfo with the then empty text from yrlvlhere in Categories.
    Just switch the sides of the assignment.

    Categories.yrlvlhere.Text = TextBox4.Text