lchicaiz Posted January 28, 2004 Posted January 28, 2004 Hi everybody I need to know when user types the underline character ( '_', ASCII code 95), but when I receive the events KeyDown, KeyPress or KeyDown, all that I get is key codes (i.e. OemMinus, code 189). I know that when the OemMinus is pressed and the "Shift" key is also pressed, then the user is typing the underline character, but I want a more general method ( API? ) to translate any KeyData / KeyCode or KeyValue into the ASCII code of the character typed by user. Thanks in advance Luis B. Chicaiza Quote
Administrators PlausiblyDamp Posted January 28, 2004 Administrators Posted January 28, 2004 To detect a key you can use Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress If e.KeyChar = "_" Then 'will get the _ key End If End Sub To get the ascii value you can use Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress Dim b() As Byte = System.Text.Encoding.ASCII.GetBytes(e.KeyChar) 'b(0) will now equal the ascii code End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
lchicaiz Posted January 28, 2004 Author Posted January 28, 2004 thanks It worked fine, thanks a lot !!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.