[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


RGB/ VB colors

Posted on 2003-10-25
Medium Priority
Last Modified: 2007-12-19
quick question about colours.

the button face of Vb is &8000000F& does nayone know what the RGB equivalent is so i can make a background in paint

neutrino Dave

thx in advance
Question by:neutrinohunter
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9620078
A color code that begins with &8 is not actually a specific color, but a specific color setting. (i.e. active window, inactive window, etc.)  The color code is defined at the system level by customizing the appearance of your system from the control panel.

With this in mind, that value you are looking for is dependent upon what is set on the target machine and can change at any time.

If you want to know the exact RGB values for YOUR system, however, donwload this neat little tool and run it.


Just click and drag the crosshairs from the "Picker" section on the right side of the form and pass it over anything on the screen to discover its RGB values.

Good luck and Happy Coding...

LVL 44

Expert Comment

ID: 9620096
a number like &H8000000F (which, by the way is the CORRECT notation) is in HEX (hexadecimal) and is the equivalent of the vaule of the Color when coded as SSRRGGBB where the SS, RR, BB, GG are the HEX values forthe Saturtion, RED, BLUE and GREEN values of the color.

The Long value of that color would be -2147483633

you can either parse the HEX string of the Number - &H8000000F  to get SS = 80 RR=00, GG=00 BB = 0F,  of you can simply use the CLng function to convert the Hex string to aLong, which is the value the the ForeGround color will accept (though I believe that it will ALSO accept a color as a HEX String with the leading &H :

&HSSRRGGBB remeber that Hex FF is 255.



Expert Comment

ID: 9620422
I think the SS portion of the color iis a flag that (when the hi bit is on) means to use the system color pallet so the color will follow the color scheme that the user configures his system.  

Therefore the SS tells the system to use the 16th (F) color (Indexes start at 0)in the system palette for this control.

 A different explination of the same thought:
When the Hi order bit is true then the number is an index into a color pallette,
not an absolute color.

Please corect me if I'm wrong.

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9620920
I think Arthur_Wood is right in saying that the correct format would be &H8000000F.
However, neutrinohunter most likely made a typo and left the H out.  

According to the VB Help file, that number is a user definable System color and simply converting it to a long would probably not produce the desired RBG value.

The following is Directly from VB6.0 Help File:
Using Direct Color Settings
Using the RGB function or the intrinsic constants to define color are indirect methods. They are indirect because Visual Basic interprets them into the single approach it uses to represent color. If you understand how colors are represented in Visual Basic, you can assign numbers to color properties and arguments that specify color directly. In most cases, it’s much easier to enter these numbers in hexadecimal.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF&). Each color setting (property or argument) is a 4-byte integer. The high byte of a number in this range equals 0. The lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

Consequently, you can specify a color as a hexadecimal number using this syntax:


The BB specifies the amount of blue, GG the amount of green, and RR the amount of red. Each of these fragments is a two-digit hexadecimal number from 00 to FF. The median value is 80. Thus, the following number specifies gray, which has the median amount of all three colors:


Setting the most significant bit to 1 changes the meaning of the color value: It no longer represents an RGB color, but an environment-wide color specified through the Windows Control Panel. The values that correspond to these system-wide colors range from &H80000000 to &H80000015.

Note   Although you can specify over 16 million different colors, not all systems are capable of displaying them accurately. For more information on how Windows represents colors, see "Working with 256 Colors" later in this chapter.

Using System Colors
When setting the colors of controls or forms in your application, you can use colors specified by the operating system instead of specific color values. If you specify system colors, when users of your application change the values of system colors on their computers, your application automatically reflects the user-specified color values.

Each system color has both a defined constant and a direct color setting. The high byte of direct color settings for system colors differs from those of normal RGB colors. For RGB colors, the high byte equals 0 whereas for system colors the high byte equals 8. The rest of the number refers to a particular system color. For example, the hexadecimal number used to represent the color of an active window caption is &H80000002&.

Expert Comment

ID: 9621845
use this method to return each colors from OLE_COLOR

Private Declare Function OleTranslateColor Lib "oleaut32.dll" (ByVal lOleColor As Long, ByVal lHPalette As Long, lColorRef As Long) As Long

Private Sub GetRGB(ByVal lColor As Long, ByRef iRed As Integer, ByRef iGreen As Integer, ByRef iBlue As Integer)
    '// Translate the color if it is system color
    Call OleTranslateColor(lColor, 0&, lColor)
    '// Now split colors
    iRed = lColor Mod &H100
    lColor = lColor \ &H100
    iGreen = lColor Mod &H100
    lColor = lColor \ &H100
    iBlue = lColor Mod &H100
End Sub

Author Comment

ID: 9622586
can anyone figure this out cos i can't

the colour i want is &H8000000F&, which is the colour of the command button face,
ive tried converting all over the pplace but still i don't get the colour.

In the form that i can use in paint.

Or does someone know of a way to get a square root, pi and number 2 and 3 in superscript on a command button

neutrino dave

any help would be appreciated

Expert Comment

ID: 9622674
what is the problem with my code. it's working perfect for the color &H8000000F&. it's first translating into a valid OLE_COLOR and then split it into Red, Green & Blue

Author Comment

ID: 9630139
can't anyone just tell me the RGB cos i dunno what to do with that.

Maybe an example of how to put it in text boxes would be nice

im not the most knowledgeable progarmmer as you may have guessed

neutrino dave

any help would be gratefully appreciated

Author Comment

ID: 9666107
plz someone

im completely baffled, and my MSDN library don't work
LVL 44

Accepted Solution

Arthur_Wood earned 120 total points
ID: 9667035
why don't you simply set the color as &H8000000F (without the LAST &)

(&H is the falg that indicatged that the value is in HEX - base 16, rahter than base 10)

which is equivalent to the LONG value -2147483633

either value should give you the SAME color - set this value as the BackColor of the button.


Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question