Results 1 to 2 of 2

Thread: Hex stuph...

  1. #1

    Thread Starter
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Red face

    Uhm. I feel dumb asking this question, 'cos it's prolly got a simple solution.

    I've got a hex number (let's call it hx) that stores a flag. and values like:

    0x01 = Is Male
    0x02 = Is Employee
    0x04 = Has Drivers License
    0x08 = Is Smoker

    If hx = 0x0A it means:

    A) The person is Not Male
    B) The person is a Employee
    C) The person does not have a drivers license
    D) The person is a smoker

    because 0x0A = 0x02 + 0x08. No other combination of those would give you 0x0A.
    and if hx = 0x07 it means:

    A) The person is Male
    B) The person is a Employee
    C) The person does have a drivers license
    D) The person is Not a smoker

    because 0x07 = 0x01 + 0x02 + 0x04.

    What I want to know is how I can calculate which of those values makes up hx.

    r0ach™
    Don't forget to rate the post

  2. #2
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136

    Haven't tried this in VB, but...

    ...in other old languages I used, you could do stuff like this:

    Code:
    If A And 1
        MsgBox "Is Male"
    End If
    If A And 2
        MsgBox "Is employee"
    End If
    If A And 4
        MsgBox "Is driver"
    End If
    If A And 8
        MsgBox "Is smoker"
    End If
    Visual Basic 6 Enterprise Edition + SP4

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