KeyPreview 属性示例
这个例子在 KeyDown 事件中创建一个窗体键盘处理器。前四个功能键显示不同的信息。要试用此例,先把代码粘贴到窗体的声明部分,然后按 F5 键。当程序运行时,按下前四个 (F1 - F4) 功能键中的任意一个。Private Sub Form_Load ()
KeyPreview = True
End SubPrivate Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1: MsgBox "F1 is your friend."
Case vbKeyF2: MsgBox "F2 could copy text."
Case vbKeyF3: MsgBox "F3 could paste text."
Case vbKeyF4: MsgBox "F4 could format text."
End Select
End Sub
这个例子在 KeyDown 事件中创建一个窗体键盘处理器。前四个功能键显示不同的信息。要试用此例,先把代码粘贴到窗体的声明部分,然后按 F5 键。当程序运行时,按下前四个 (F1 - F4) 功能键中的任意一个。Private Sub Form_Load ()
KeyPreview = True
End SubPrivate Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1: MsgBox "F1 is your friend."
Case vbKeyF2: MsgBox "F2 could copy text."
Case vbKeyF3: MsgBox "F3 could paste text."
Case vbKeyF4: MsgBox "F4 could format text."
End Select
End Sub
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货