[thechat] Visual Basic Help? SHIFT key
Syed Zeeshan Haider
szh at softhome.net
Fri Oct 25 01:14:00 CDT 2002
Hello Everybody,
I need some help from Visual Basic experts here.
Here is a code from MSDN library:
<Visual Baisc>
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
ShiftTest = Shift And 7 'needs explanation
Select Case ShiftTest
Case 1 ' or vbShiftMask
Print "You pressed the SHIFT key."
Case 2 ' or vbCtrlMask
Print "You pressed the CTRL key."
Case 4 ' or vbAltMask
Print "You pressed the ALT key."
Case 3
Print "You pressed both SHIFT and CTRL."
Case 5
Print "You pressed both SHIFT and ALT."
Case 6
Print "You pressed both CTRL and ALT."
Case 7
Print "You pressed SHIFT, CTRL, and ALT."
End Select
End Sub
</Visual Baisc>
The third line in above code is:
ShiftTest = Shift And 7
The result of bit-wise comparison of Shift and 7 is stored in ShiftTest.
Why is this comparison necessary?
Can't we accomplish the same task without this comparison?
Thank you,
Syed Zeeshan Haider.
http://syedzeeshanhaider.faithweb.com/
More information about the thechat
mailing list