将窗体的KeyPreview属性设为True,然后编写如下程序: Private Sub Form_KeyDown(KeyCode As Integer,Shift As Integer) Print Chr(KeyCode) End Sub Privat

admin2020-04-18  27

问题 将窗体的KeyPreview属性设为True,然后编写如下程序:
Private Sub Form_KeyDown(KeyCode As Integer,Shift As Integer)
Print Chr(KeyCode)
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
Print Chr(KeyAscii)
End Sub
运行程序时,按下字母键a,则窗体上显示的是

选项 A、A
A
B、A
a
C、a
A
D、a
a

答案B

解析 KeyCode是按键的实际字符(不区分大小写),KeyAscii是以字符为准,是所按键的ASCII码。
转载请注明原文地址:https://kaotiyun.com/show/spTp777K
0

最新回复(0)