ADIGA88
Member
- Local time
- Today, 05:39
- Joined
- Apr 5, 2020
- Messages
- 94
Hi guys,
I came across strange use of the
In the example, they use the
While (acShiftMask, acAltMask, acCtrlMask) are evaluate ( 1, 4, 2)
Thanks
I came across strange use of the
AND
Operator and I couldn't explain it if someone could shed some light on it. I found this example in the Access VBA MS Docs.In the example, they use the
AND
to compare integers and it's not what you think (-1, 0)
Code:
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."
End Sub
Thanks