RGB/ VB colors

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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
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...

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.


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.

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
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&.
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
neutrinohunterAuthor Commented:
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
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
neutrinohunterAuthor Commented:
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
neutrinohunterAuthor Commented:
plz someone

im completely baffled, and my MSDN library don't work
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.