Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Colors 24 Bits and Binary Conversion

Introduction.

If you were following the last four Articles on Number  Systems (Decimal, Binary, Octal, and Hexadecimal) then here is something for you to play with.  Before that following is the list of Links to those Articles. It is better if you take a look at them before continuing. You will be in a better position to understand it, appreciate its usefulness, and can enjoy working with its methods.

  1. Learn Binary Numbering system
  2. Learn Binary Numbering system-2
  3. Octal Numbering System
  4. Hexadecimal Numbering System

Color Number Range 0 to 16 Million.

The above is an image of an MS-Access Form where you can enter a Decimal Number, ranging between 0 and 16777215 (equal to a maximum of 24 Bit Binary Value), and get it converted into a Binary Number.  At the same time, the number entered into the TextBox will be used for generating the RGB Color that will be displayed at the top color band, where the binary bit positional sequence numbers are shown. Logically, you can display a total of over sixteen million colors on the top color band on the form.

If you look closely at the image above, you can see that the value 65535 is entered into the text box and the Binary digits 1111111111111111 are appearing in the gray band above the Text Box.  The decimal value equal to each bit position is in the red font color of the labels arranged vertically above the binary digits. If you add up all those red-colored values together, you will get the result equal to the value in the text box.

The Red, Green, and Blue (RGB) Colors.

Binary bit number 0 to 7 (8 bits) values give the Red Color and bit number 8 to 15 (8 bits) values from the Green Color.  When Red and Green Colors are mixed you will get Yellow Color shown on top of the Red, Green & Blue Color bands.

Let us make a little modification to the above sample color by subtracting some bit values, and see how the color changes on the top color band.  Click on the labels with the values 4096 and 64 one by one.  These values are moved into the TextBox and will be subtracted from 65535 (the sample number already appearing in there). The color of the labels changed back to its default color black.  Click on the Command Button with the label Convert. The result value (RGB Number) appears in blue color below the text box and the RGB Color of that number is now showing on the top color band. See the image given below:

If you want to add some more color (Red, Green, or Blue) to the existing color number you can click on the labels with numbers in black color, mix the color above those labels, and click Convert Command Button to show the result on the top band.  The intensity of the color added depends on the magnitude of the number selected from within the respective color band. The color of the label clicked will change to red indicating that the value is added to the color number.

If you click on the labels with red-colored font again, it will change to black indicating that those values will be subtracted from the color values.  You must click on the Convert Command Button to evaluate the final color value and display the color on the top color band. Every time the Binary digits of those values will also appear in the gray band above the Text Box as well.

To reset everything back to the default setting, click on 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:

  1. Enter a Decimal Number into the TextBox and Click on the Convert Command Button.
  2. Enter a valid expression into the Text Box like 2^10+2^5+5*25+1638 and click Convert Command Button.
  3. Click on the labels showing the binary digit values underneath Red, Green & Blue color bands to pick those color numbers and mix them together to create a new color. Each value clicked will be added to the Text Box in the form of an expression. Each Label clicked will change its font color to Red indicating it is added to the color number and if any of those labels are clicked again that color value will be subtracted and the label font color will change back to default black.  When done, click Convert Command Button.
  4. You can use a mix of all the three methods given above to input a valid expression to arrive at a valid value between 1 and 16777215 (16777215 = 256 Blue * 256 Green * 256 Red -1)

Get the result in three ways:

  1. The RGB Color equal to the number selected is displayed on the top color band.
  2. The Binary Number.
  3. The RGB Color Number of the top color band.

How to Use the Newly Created Color.

You can use this Color Number while designing your Forms or Controls to set the Background Color, Foreground Color, or Border Color on the Property Sheet of the Form or Control.  If you are a Web Designer, convert the Color Number into the HexaDecimal Number, and use it on the Style Sheets.  You can call the Function HEX$(Decimal Number) in Debug Window to convert it into a HexaDecimal value.  Use the color value in the 24-bit format like #0000FF for decimal color value 255.

Enter the number 16777215 in the Text Box and click 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:

Technorati Tags:

Download Demo Database

Download Demo Binary.zip


Share:

No comments:

Post a Comment

Comments subject to moderation before publishing.

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Class Module External Links Queries Array msaccess reports Accesstips WithEvents msaccess tips Downloads Objects Menus and Toolbars Collection Object MsaccessLinks Process Controls Art Work Property msaccess How Tos Combo Boxes Dictionary Object ListView Control Query VBA msaccessQuery Calculation Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes RaiseEvent Recordset Top Values Variables Wrapper Classes msaccess email progressmeter Access2007 Copy Excel Export Expression Fields Join Methods Microsoft Numbering System Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code