【发布时间】:2018-08-23 16:14:50
【问题描述】:
我希望使用 Access 键事件,但需要更好地了解代码的工作原理。在下面的代码中,我不明白“(Shift And acShiftMask)> 0 ”是如何工作的。如果有人能帮助我理解位掩码以及以下代码的工作原理,我将不胜感激?
Private Sub KeyHandler_KeyDown(KeyCode As Integer, _
Shift As Integer)
Dim intShiftDown As Integer, intAltDown As Integer
Dim intCtrlDown As Integer
' Use bit masks to determine which key was pressed.
intShiftDown = (Shift And acShiftMask) > 0
intAltDown = (Shift And acAltMask) > 0
intCtrlDown = (Shift And acCtrlMask) > 0
' Display message telling user which key was pressed.
If intShiftDown Then MsgBox "You pressed the SHIFT key."
If intAltDown Then MsgBox "You pressed the ALT key."
If intCtrlDown Then MsgBox "You pressed the CTRL key."
结束子
【问题讨论】: