PDA

Click to See Complete Forum and Search --> : Splitting Bits from an Integer


Nov 25th, 1999, 07:39 PM
The GetKeyState function returns a Integer containing information about the specified key.

For keys such as Caps Lock etc, the first bit (bit 0) of the returned value is true of the key is toggled.

How can I split up the integer in order to correctly read this bit?

Thanks;
Richard Moss

------------------
Richard Moss

ariad@globalnet.co.uk
http://www.users.globalnet.co.uk/~ariad/

Joacim Andersson
Nov 25th, 1999, 08:36 PM
The bits equals the values 1, 2, 4, 8 and so on so you can break them out like this:

If iReturnValue And 1 Then 'bit 0
'Do whatever
End If
If iReturnValue And 2 Then 'bit 1
'Do whatever
End If
If iReturnValue And 4 Then 'bit 2
'Do whatever
End If
'and so on...

Good luck!

------------------
Joacim Andersson
joacim@programmer.net
joacim@yellowblazer.com
www.YellowBlazer.com (http://www.YellowBlazer.com)

Nov 25th, 1999, 10:03 PM
Joacim,

That work's brilliantly, thanks a lot!




------------------
Richard Moss

ariad@globalnet.co.uk
http://www.users.globalnet.co.uk/~ariad/