默认情况下,PgUp 和 PgDn 键用于在窗体中的记录之间导航。 以下示例演示如何使用窗体的 KeyDown 事件来禁用窗体中的 PAGE UP 和 PAGE DOWN 键。
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
' The Keycode value represents the key that
' triggered the event.
Select Case KeyCode
' Check for the PAGE UP and PAGE DOWN keys.
Case 33, 34
' Cancel the keystroke.
KeyCode = 0
End Select
End Sub
注意
必须将窗体的 KeyPreview 属性设置为 True ,此过程才能正常工作。
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。