Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reverse Bitwise Operations

0 views
Skip to first unread message

James Arnold

unread,
Feb 14, 2007, 12:27:59 PM2/14/07
to
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!

Herfried K. Wagner [MVP]

unread,
Feb 14, 2007, 12:52:59 PM2/14/07
to
"James Arnold" <jar...@gmail.com> schrieb:

> 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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

0 new messages