How to read the key pressed by user and get its unicode value in VB 2010 ?

Terkunci How to read the key pressed by user and get its unicode value in VB 2010 ?

  • 27 Juni 2012 6:38
     
     

    Hi I am using Unicodes for the first time. 

    This is my situation I have a rich text box and I need to to know which key user pressed and get its Unicode value for comparison in a switch case statement. Could somebody please give the code for the same in VB 2010 .

    Thanks in advance.


    Jithu R Jacob My current Project : https://sourceforge.net/projects/harisree/files/Harisree/

Semua Balasan

  • 27 Juni 2012 13:45
     
     Jawab Memiliki Kode

    Handle the KeyPress event. The character in e.KeyChar represents the Unicode character. To get the numeric value, call

          Dim codepoint As UInt16
    
          codepoint = Convert.ToUInt16(e.KeyChar)

    EDIT: Of course, for a Select Case statement, you can also just write

    select case e.keychar

    case "A"c

    case "B"c

    End select


    Armin