# [SOLVED] Input box username VB2010



## owain (Oct 26, 2009)

VB 2010:
Im having a username input box that i want to be displayed in a label when the username confirms his username, i can only seem to get this to work when i have a button that you have to click to get it to be displayed in the label how do i make it get displayed in the label straight after it has been typed in without a button?


----------



## niemiro (Feb 20, 2010)

*Re: Input box username VB2010*

Hello!

I know what this is for...but I think it is specific for me to help you with. Why would you want to do that, would be my question?

Let's say that I am not a very confident user. I may have to think about my user name for a bit. I might be a slow typer. I might even have to test several different user names. Turning your editable text box into a non editable label is not the right way to deal with this, and will prevent this user from logging in.

You must leave it as a text box.

Richard


----------



## owain (Oct 26, 2009)

*Re: Input box username VB2010*

All i want is a simple username that just appears in the label or text box after it is typed into the input box

I have got the input box opening on form load:

Private Sub singleplayer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strName As String
strName = InputBox("Enter your username:", "Input Test")
End Sub

Then i try to get the username that was chosen by typing:

Private Sub lblusenrame_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblusername.Click
lblusername.text = strName
End Sub

and i have the strName declared as String aswell but it doesnt work it comes up with no errors but still the username doesnt appear in the label

What exactly am i doing wrong?
Should i be using text box instead of label?


----------



## niemiro (Feb 20, 2010)

*Re: Input box username VB2010*

Hello!

Ah! I understand want you want to do now!

It should work. I notice that you are splitting things up a bit there. Why do you want to wait for the Label to be clicked on? .Text should have a capital T, and strName will not be accessible from within that other sub.

What about this:


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

        Dim strName As String
        strName = InputBox("Enter your username:", "Input Test")
        Label1.Text = strName

        Label1.Text = InputBox("Enter your username:", "Input Test")

End Sub
```
Both of those methods will work. The second is more efficient, yet less readable. Use two different user names, and watch it change twice!

Richard


----------



## owain (Oct 26, 2009)

*Re: Input box username VB2010*

Ahh works great now thank you for your help niemiro


----------



## niemiro (Feb 20, 2010)

*Re: Input box username VB2010*

You're welcome. Glad I could be of assistance.


----------

