Private Sub form_keyDown(KeyAscii As Integer, shift As Integer)   If KeyAscii = 13 Then
   MsgBox "hah"
   End IfEnd SubPrivate Sub Form_Load()
  Me.KeyPreview = True
End Sub
为什么把"13" 换成 "59" 就不能用了???

解决方案 »

  1.   

    Private Sub Form_KeyPress(KeyAscii As Integer)
       If KeyAscii = 59 Then
          MsgBox "hah"
       End If
    End Sub
      

  2.   

    我在其他机子上试了
    也不行啊!!在KeyPress事件里写,你试过没有:Private Sub Form_KeyPress(KeyAscii As Integer)
       If KeyAscii = 59 Then
          MsgBox "hah"
       End If
    End Sub
      

  3.   

    我没那么苯拉
    我买了一个磁卡读卡器
    是键盘借口的
    用银行卡一刷,出现下面一行的东西
    ;955592xxxxxxxx=06xxxxxxx3?我要根据";"来触发我的键盘捕获程序
    然后跟数据库对比各位有没什么好的思路??提供代码是最好拉
      

  4.   

    我也试了不行啊。我按下";"这个键,监测到的代码是186而不是59,而且那个按下方向键的时候根本就不触发KeyPress和KeyUp等事件,怎么回事啊?
      

  5.   

    刚再试了一下,发现其它的键都能触发keypress事件,就是那几个方向键和pageup,pagedown那几排的键没法触发keypress事件,什么原因啊?
      

  6.   

    我是在Change事件中,干脆过滤掉了非数字的字符.
      

  7.   

    那几个是KeyKode,而不是KeyAscii
    要不换成Form_KeyDown或Form_KeyUp事件试试
      

  8.   

    乱套了,其它的按键用keypress来获得的值都和资料上的不一样,按W居然得到了119.越来越糊涂了。
      

  9.   

    哈有点神奇吧?
    我查了,还有人用一个text来存刷进的植
      

  10.   

    为什么用keydown和keypress得到得按键的代码是不一样的啊?
      

  11.   

    keydown,keypress,keyup 得到的KEYCODE不是ASC码 而是键盘扫描码
    59应该事指F5那个键~
      

  12.   

    错了 59好象没有扫描码
    我的系统是WIN2003不知道系统对这个有没有影响
      

  13.   

    Private Sub form_keyDown(KeyAscii As Integer, shift As Integer)   If KeyAscii = asc(";") Then
       MsgBox "hah"
       End IfEnd Sub
    这样不会错了吧!??
      

  14.   

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)End SubPrivate Sub Form_KeyPress(KeyAscii As Integer)End Sub
    注意了吗  1个是KEYCODE 1个是KEYPRESS
    但是 在 其中任何1个时间中都可以引用Keycode值
      

  15.   

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
      Print KeyCode
    End Sub
    Private Sub Form_KeyPress(KeyAscii As Integer)
      Print KeyAscii
    End SuB
    试试这个就知道了
      

  16.   

    Private Sub form_keyDown(KeyAscii As Integer, shift As Integer)   If KeyAscii = Asc(";") Then
       MsgBox "hah"
       End IfEnd SubPrivate Sub Form_Load()
      Me.KeyPreview = True
    End Sub
      

  17.   

    不知道为什么啊,还是不行

    Private Sub form_keyDown(KeyAscii As Integer, shift As Integer)   If KeyAscii = Asc(";") Then
       MsgBox "hah"
       End IfEnd SubPrivate Sub Form_Load()
      Me.KeyPreview = True
    End Sub没用!
      

  18.   

    首先讀取keyascii的值
    Private Sub form_keyDown(KeyAscii As Integer, shift As Integer)msgbox keyasciiEnd Sub
    知道后再做判斷!
      

  19.   

    Private Sub form_keyDown(KeyCode As Integer, shift As Integer)   If KeyCode= Asc(";") Then
       MsgBox "hah"
       End IfEnd Sub
      

  20.   

    我也不行,不过
    Private Sub Form_KeyPress(KeyAscii As Integer)
       If KeyAscii = 59 Then
       MsgBox "hah"
       End If
    End SubPrivate Sub Form_Load()
      Me.KeyPreview = True
    End Sub
    就可以了!