各位高手,我寫了一個抓取鍵盤訊息的小程式,如下:
在Form上放一個Label,86個按鈕(用一個按鈕來複製成陣列)
Private Sub Form_KeyDown(keycode As Integer, shift As Integer)
GetAsciicode (keycode)
KeyPressed (keycode)
End Sub
Private Sub KeyPressed(keycode As Integer)
Select Case Asc(Chr(keycode))
Case 27 'ESC鍵-->被按到的鍵失能並且變色
Command1(0).Enabled = False
Command1(0).BackColor = &H400000
Case 9 'Tab鍵
Command1(17).Enabled = False
Command1(17).BackColor = &H400000
Case 13 'Enter鍵
......
'總共有86個鍵
End Select
End Sub
Private Sub GetAsciicode(keycode As Integer)
Label1.Caption = "The Ascii code is : " & Asc(Chr(keycode)) & " The Key is : " & Chr(keycode)
End Sub
小弟才剛學使用VB6,還粉生疏,請問這個陣列要如何的來使用才會比較簡潔呢?另外再問一個問題:上下左右鍵的Ascii code要如何才能夠抓的到?