Introduction.
If you have been following the last four articles on Number Systems (Decimal, Binary, Octal, and Hexadecimal), here’s something interesting for you to explore. Before we dive in, I recommend reviewing those earlier articles using the links provided below. Doing so, you know the background information on this topic, understand the concept more clearly, appreciate its practical usefulness, and enjoy experimenting with the methods we are about to discuss.
- Learn the Binary Numbering System
- Learn Binary Numbering System-2
- Octal Numbering System
- Hexadecimal Numbering System
Color Number Range 0 to 16 Million.
The image above shows an MS-Access Form where you can enter a Decimal Number ranging from 0 to 16,777,215 (the maximum value represented by a 24-bit binary number). The form converts the entered value into its Binary equivalent and simultaneously uses the number to generate an RGB color, displayed in the top color band. With this method, you can visualize over 16 million possible colors on the form.
In the example shown, the value 65535 is entered in the text box. The corresponding Binary representation (1111111111111111) is displayed in the gray band just above the text box. Each binary digit is aligned under a label in red font, which represents the decimal value of that bit position. By adding together all these red-labeled values where the binary digit is 1 You arrive at the decimal number entered in the text box.
The Red, Green, and Blue (RGB) Colors.
Bits 0 to 7 (the first 8 bits) represent the Red component, while bits 8 to 15 (the next 8 bits) represent the Green component. When both Red and Green are at full strength, they combine to produce Yellow, which is displayed on the top color band above the Red, Green, and Blue bars.
Now, let’s slightly modify this sample color. Starting with the value 65535, click on the labels with the values 4096 and 64. Each selected value is transferred into the text box and subtracted from 65535. The clicked labels return to their default black font color, indicating that those bit values are no longer active.
Finally, click the Convert command button. The updated result (the new RGB number) is displayed in blue beneath the text box, and the top color band updates to show the new color generated after subtracting the selected bit values. See the image below for reference.
If you would like to add more Red, Green, or Blue to the existing color number, simply click on the labels that display numbers in black font. Each selected value will be added to the current color, and when you click the Convert command button, the new result will be displayed in the top color band. The intensity of the added color depends on the magnitude of the number chosen within the respective color band. Once a value is included, its label font changes to red, indicating that it has been added to the current color number.
If you click a label that is already red, its font will switch back to black, meaning that value will now be subtracted from the total. Again, click the Convert command button to evaluate the final color value. The updated binary digits of the selected values will appear in the gray band above the text box each time, allowing you to trace which bits are active.
To restore the form to its default state, click the Reset command button.
How to make a Color Choice?
You can use one of the three methods given below or a mix of all three to enter the number into the TextBox:
- Enter a Decimal Number directly into the TextBox and click the Convert command button. 
- 
Enter a valid expression into the TextBox (for example: 2^10 + 2^5 + 5*25 + 1638) and click the Convert command button. The expression will be evaluated, and the result will be converted.
- 
Click on the labels beneath the Red, Green, and Blue color bands to select values and combine them into a new color. Each clicked value is added to the TextBox as part of an expression, and its label font changes to red, showing it has been included. Clicking the same label again will subtract that value, and the font will revert to black color. When ready, click the Convert command button to apply the result. 
- 
You can also combine all three methods—direct number entry, expressions, and label selections—to arrive at a valid color number between 1 and 16,777,215 ( 16777215 = 256 Blue × 256 Green × 256 Red – 1).
Get the result in three ways:
- The RGB Color equal to the number selected is displayed on the top color band.
- The Binary Number.
- The RGB Color Number of the top color band.
How to Use the Newly Created Color.
You can use this color number when designing Forms or Controls in Access by setting it as the Background, Foreground, or Border Color in the Property Sheet of the Form or Control. If you are a web designer, you can convert the decimal color number into a hexadecimal value and use it in your style sheets. To do this, call the function Hex(DecimalNumber) in the Debug Window. The result will give you the 24-bit hexadecimal format, which can be applied directly in CSS, for example: #0000FF for the decimal color value 255.
Enter the number 16777215 in the Text Box and click the Convert Command Button to change the top color band to white.
You can download a database with the above Form and Programs by clicking on the Download link below:
Download Demo Database
 Download Demo Binary.zip
Download Demo Binary.zip










 
 
 

No comments:
Post a Comment
Comments subject to moderation before publishing.