Reverse Bitwise Operations

  • Thread starter Thread starter James Arnold
  • Start date Start date
J

James Arnold

Say I have an enumeration of modifiers for a hotkey (which
conveniently I do!):

Private Enum HotkeyModifier
None = 0
Alt = 1
Ctrl = 2
Shift = 4
Win = 8
End Enum

Using this I can work out the modifier for Ctrl and Alt being pushed
(1 + 2). However, if I was given a value (e.g. 7), how would I extract
the individual modifiers used?

i.e.
7 -> Alt + Ctrl + Shift
5 -> Alt + Shift

....etc. Thanks again!
 
James Arnold said:
Say I have an enumeration of modifiers for a hotkey (which
conveniently I do!):

Private Enum HotkeyModifier
None = 0
Alt = 1
Ctrl = 2
Shift = 4
Win = 8
End Enum

Using this I can work out the modifier for Ctrl and Alt being pushed
(1 + 2). However, if I was given a value (e.g. 7), how would I extract
the individual modifiers used?

\\\
If CBool(Value And HotkeyModifier.Alt) Then
...
End If
///
 
Back
Top