Hi,Guys!
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

Recommended Answers

All 4 Replies

Look at example code attached.

Enjoy Mark as solved if solved.

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!

Be a part of the DaniWeb community

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