Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need algorithm
Message
From
07/07/2011 10:31:53
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Games
Category:
Trivia
Title:
Miscellaneous
Thread ID:
01517506
Message ID:
01517585
Views:
44
>What I don't understand is how do you go from bit to number that will be stored in the field. For example, say only the 1st option box is selected. Does it mean that the value of 1 is set to the field? And if Option 1 and 2 are selected, the value of 3 is set to the field? And in case of all three options boxes, the value is 7?

The options have numerical values 1, 2, and 4 assigned (for more than 3 options, use additional powers of 2: 8, 16, etc.). If one bit is set, add the values of the individual bits, e.g. 101(binary) = 4 + 1. To get the combined value:
CombinedValue = iif(CheckBox0.Value, 1, 0) + iif(CheckBox1.Value, 2, 0) + iif(CheckBox2.Value, 4, 0)
* (Assuming you changed the checkbox to a logical type. Otherwise, use iif(CheckBox.Value = 1...))
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform