I am currently making a project and got stuck.(I am a total beginner)
The program is for users to submit their username by typing in their username and pressing the submit button. The username may be able to display on the Usernamelabel in form1.(I made the button on form2)
I have problems coding to make the text to come out in form2.My code comes out as error.
Anyone can help to solve this?

Here is the code in form2.

Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
     UserNameTextBox.Text = UserNameLabel.Text

    End Sub
End Class
6 Years
Discussion Span
Last Post by TrueVb.NetNoob

Thank you so much finito for the code!!!!!

But does it work if u change the label in form2 into a textbox instead?

And I didn't get this part.

Public Function GetLbl() As String

        Return Label1.Text

    End Function

I assume since you marked it as solved you figured out that the answer is yes.

Good Luck


Sry about that.

Yes,I kinda just replaced your code with textbox.text and it did work!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.