怎样实现在keypress事件中获取输入字符的ASCII码?分不多,小问题!

解决方案 »

  1.   

    例如 
    Private Sub Form_KeyPress(KeyAscii As Integer)
    text1.text=keyascii
    End Sub
      

  2.   

    Private Sub Form_KeyPress(KeyAscii As Integer)
        Text1 = KeyAscii
    End SubPrivate Sub Form_Load()
        Form1.KeyPreview = True
    End Sub
      

  3.   

    在控件如text1的keypress事件中写上
       KeyAscii = Asc(UCase(Chr(KeyAscii)))
       keyascii就是你想得到的值
      

  4.   


    在键盘的点击事件中
    text1.text=keyascii
      

  5.   

    以上代码要设置窗体的KeyPreview属性为True你可以在一个Text控件的keypress里试啊!Private Sub Text1_KeyPress(KeyAscii As Integer)
    Me.Caption = KeyAscii & "  " & Chr(KeyAscii)
    End Sub
      

  6.   

    Private Sub Text1_KeyPress(KeyAscii As Integer)
        text1.text=""
        msgbox "你所按键的字符ASCII码为:" & KeyAscii
    end sub