Results 1 to 3 of 3

Thread: Splitting Bits from an Integer

  1. #1
    Guest

    Post

    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

    [email protected]
    http://www.users.globalnet.co.uk/~ariad/


  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Post

    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
    [email protected]
    [email protected]
    www.YellowBlazer.com



  3. #3
    Guest

    Post

    Joacim,

    That work's brilliantly, thanks a lot!




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

    [email protected]
    http://www.users.globalnet.co.uk/~ariad/


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width