i created a simple keyboard in vb.net , the problem is i got 2 textboxes, but when i tried to use the keyboard that i've created in textbox1, i got the same result in textbox2[ in short what i type in textbox1 it also textbox2]

 if textbox1.[dont know what to put] then
          textbox1.text = (textbox1.text + "a")
        else 
           textbox2.text = (textbox2.text + "a")
           end if

Can you be more clear about of what is going wrong? Also what do you mean by "created a keyboard in textbox1"?

@Minimalist , sorry about that
i have a keyboard[form1]
2 textboxes

when i tried to run it and us the keyboard , the text in textbox 1 is the same as textbox2, its like automatic,what i type in textbox1 is also appearing in textbox2 at the same time

when i am inputting a text in textbox1 the text is need to be in textbox1 only, also in textbox2
example,i input "ABCDEF" in textbox1 then i want to input "MNBVCX" in textbox2
the text dont need to be connected the 2 textboxes, but i code it connected, ,,please help me

this is my code:

Private Sub btna_Click(sender As System.Object, e As System.EventArgs) Handles btna.Click
        If TextBox1.[dont know what to type here] = True Then
            TextBox1.Text = (TextBox1.Text + "a")
        End If
        If TextBox2.[dont know what to type here] = True Then
            TextBox2.Text = (TextBox2.Text + "a")
        End If
           End Sub

the 2nd picture is the output
[the letter "a" both type in textbox1 & 2 ,but i want to separate, like i want to type in textbox 1 but not affecting the other textbox]

Attachments Untitled.png 7.92 KB output.jpg 28.79 KB

You have to give us actual code.

If TextBox1.[dont know what to type here] = True Then 

does not qualify. May I also suggest you name your controls more clearly. For example, txtUsername and txtPassword instead of TextBox1 and TextBox2.

And your explanation is still very confusing.

My actual code:

Public sub BtnA_Click(sender As System.Object, e As System.EventArgs) Handles BtnA.Click
    txtusername.text = (txtusername.text + "A")
End sub

i want to input a text in txtpassword but i dont know how?because the button is only connected to txtusername.

Assuming this is some sort of login form, what you would usually do it compare the entered username and password to a stored username and password (such as in a database). Since I don't know what you are comparing it to I'll just use literals as

If txtUsername.Text = "Bilbo" And txtPassword.Text = "Baggins" Then
    MsgBox("Access granted")
    LoggedIn = True
Else
    Msgbox("Incorrect login")
    LoggedIn = False
End If

The problem with using an onscreen keyboard is that as soon as you click on a key whatever textbox you were in loses focus so you have to keep track of what control you were just in. You can do that by declaring a class level variable like

Private currText As TextBox = Nothing

Then in the Enter event for each textbox you set the value like

Private Sub txtUsername_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtUsername.Enter
    currText = sender
End Sub

In the Click event for your keyboard keys you can do

If Not currText Is Nothing Then
    currText.Text &= "A"
End If

You could even generalize the keyboard to use the same event handler for all of the keys. That would be the preferrred way since all of the keys have the same code except for that actual key entered (which can be determined from the displayed value on the key).

By the way, you should be using & to concatenate strings instead of using +. It would also be a good idea to give the user some feedback as to which textbox will receive the keyboard clicks. I suggest changing the backgrouund colour (you could do this in the Enter event). You will have to decide when to restore the original colour. Obviously youu can't do this in the Leave event as this fires as soon as you click on a key.

Edited 1 Year Ago by Reverend Jim

@Reverend Jim, i got it now. thank you so much . It really help me so much. :D

This question has already been answered. Start a new discussion instead.