Q:

Visual Basic - how to prevent keyboard keys in textbox

I want to create a program like this site http://www.lexilogos.com/clavier/araby.htm. When I click on a key like for example "m" it writes "م", so i programmed the buttons in the Visual Basic program to send keystrokes to a textbox. When I tried the code below, when I hit a keyboard key it clicked on the button in Visual Basic that sends the keystroke
If (GetAsyncKeyState(65)) Then
    Button19.PerformClick()
End If

and it works but it also write the normal keyword that I hit, so it writes two keywords, for example the "m" and "م".
Is there any solution? 

A:

In the event for the Key pressed (KeyPressed or KeyDown), just assign:
e.Handled = true

This will prevent the letter to appear on the TextBox. Check is MSDN Documentation about it.

You can do a workaround too, but I don't recommend it. Simply handle the TextChanged event of the TextBox and delete the text:
Sub TB_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
    TextBox1.Text = ""
End Sub

A:

You can try that:
Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = "a" Then
            e.KeyChar = "1"
        End If
    End Sub

.

