VB怎样实现锁定键盘上的一些键?

2024-12-11 21:14:34
推荐回答(2个)
回答1:

凑个热闹:
Private Sub Form_Load()
Me.KeyPreview = True
End Sub

Private Sub Form_KeyPress(Key As Integer)
被锁字符集 = "ABCa啊" '你可以将想锁定的任何键或字符放在该字符串中
Key = IIf(InStr(被锁字符集, Chr(Key)) > 0, 0, Key)
End Sub

回答2:

Private Sub Form_Load()
Me.KeyPreview = True
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = Asc("A") Then KeyAscii = 0 '锁定A
If KeyAscii = Asc("a") Then KeyAscii = 0 '锁定a
'.......
End Sub