key change on press question

ok well i have a question for one i am using vb express 2005 and i am wanting to pretty much make a program that will send what ever i type to a text area but i want keys to be different i am pretty sure i cna find out what code sends the text ot the area but will this code work for me if i set it for every key i need

System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.A Then
e.SuppressKeyPress = True
If e.Shift Then SendKeys.Send("B") Else SendKeys.Send("b")

and if so why is it when i put it in my project it give me erroes on all of it maybe im not writeing it right but its excatly the same in my project as i have in this post

i egearly await a reply



Answer this question

key change on press question

  • Brucec

    Public Class Form1

    Dim hold As System.Windows.Forms.KeyEventArgs = Nothing

    Private Sub TextBox1_KeyDown(ByVal sender As Object, _

    ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown

    hold = e

    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, _

    ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

    ' True for 'a' or shifted 'a'

    If hold.KeyValue = Asc("A") Then

    If hold.Shift Then

    ' ("A was typed")

    ' Replace it with accented big A

    e.KeyChar = CChar(("A"))

    Else

    '("a was typed")

    ' Replace it with accented little A

    e.KeyChar = CChar(("a"))

    End If

    End If

    End Sub

    End Class



  • caution812

  • desny

    well there was more promblems with in the project so i jsut started new and yeah theres where i need to be but lets say when i push the a key i want it to

    a

    and wheh shift is pressed i want it to show

    A will that code i posted in the frist post work for this

    and by the way i got no more errors but i just wanan makre sure i get this right cuz their is a lot of keys i ahve to change and i dont wanan have to go back and fix everyone if i have the wrong code


  • AlistairSKing

    well the signature is incorrect for the method. it should be this....

    double click on the keydown event in the form events (click on form in main designer, click on the events tab (lightning symbol) and download click the keydown event)

    you should then get something like this in code view...

    private sub Form1_KeyDown(byval sender as object, byval e as System.Windows.Forms.KeyEventArgs) handles Me.KeyDown

    end sub

    in between this, you paste in the code you want

    what errors do you get it would help if you can post them



  • key change on press question