VBColor

mr moe

Registered User.
Local time
Today, 13:21
Joined
Jul 24, 2003
Messages
332
Does anyone know where I can get a list of vb color codes, I had a table long time ago but I lost the file. It had the displayed color and it's vb code. Thanks in advance.
 
Here you go......

Regards
 

Attachments

While that's a nice example database, mhartman, it doesn't really answer the question of providing a list of the Visual Basic colour constants, of which there are only eight. These are detailed in the help files that ship with access.
 
Type "color constants" in to Access help, and it's amazing what the very first result is... ;)

With that in mind, there are only eight specific to VB in general:

Code:
[U]Constant[/U]    [U]Value[/U]
vbBlack     0 
vbRed       255  
vbGreen     65280
vbYellow    65535 
vbBlue      16711680 
vbMagenta   16711935 
vbCyan      16776960
vbWhite     16777215

However, those are stored as Long Integers (four bytes) as opposed to the sixteen built-in to Access that are stored as one byte:

Code:
[U]Constant[/U]                  [U]Value[/U] 
acColorIndexAqua          14 
acColorIndexBlack         0 
acColorIndexBlue          12 
acColorIndexBrightGreen   10 
acColorIndexDarkBlue      4 
acColorIndexFuschia       13 
acColorIndexGray          7 
acColorIndexGreen         2 
acColorIndexMaroon        1 
acColorIndexOlive         3 
acColorIndexRed           9 
acColorIndexSilver        8 
acColorIndexTeal          6 
acColorIndexViolet        5 
acColorIndexWhite         15 
acColorIndexYellow        11

Both work the same; e.g., MyControl.ForeColor = acColorIndexWhite and MyControl.ForeColor = vbWhite produce the same result. The former just takes less memory.
 
Thanks Mhartman, that's what i was looking for.
 
And, were you aware that you can go into a form in design mode and set it's color using the color select, including creating your own shade, and then you can take the resulting number and assign it and get that color?

So, for example, if I go into the color select and decide on this washed out shade of blue, it returns this number: 13420970 which I can then assign via code -
MyControl.ForeColor = 13420970
 
If you go into the object browser (from a module page) and search for Color one of the things you will get back is a list of color codes including the codes that link to windows. I.e. a color that isn't a color but is rather an index to the table of Windows color codes that your machine uses. These things include the standard background, standard title bar, highlighted item colors, etc. etc. - so tht you can automagically integrate your color scheme to the Windows scheme. If you change schemes later, things using the color indexes follow the change.
 
To beat a dead horse:
The VB color code from RGB format is as follows:
(R * 1) + (G * 256) + (B * 65536)

Kaboom, vb color.
 
I knew it... this forum kicks ass n.n ...

(Please forgive if this comment is out of place n.n")
 
Type "color constants" in to Access help, and it's amazing what the very first result is... ;)

With that in mind, there are only eight specific to VB in general:

Code:
[U]Constant[/U]    [U]Value[/U]
vbBlack     0 
vbRed       255  
vbGreen     65280
vbYellow    65535 
vbBlue      16711680 
vbMagenta   16711935 
vbCyan      16776960
vbWhite     16777215
However, those are stored as Long Integers (four bytes) as opposed to the sixteen built-in to Access that are stored as one byte:

Code:
[U]Constant[/U]                  [U]Value[/U] 
acColorIndexAqua          14 
acColorIndexBlack         0 
acColorIndexBlue          12 
acColorIndexBrightGreen   10 
acColorIndexDarkBlue      4 
acColorIndexFuschia       13 
acColorIndexGray          7 
acColorIndexGreen         2 
acColorIndexMaroon        1 
acColorIndexOlive         3 
acColorIndexRed           9 
acColorIndexSilver        8 
acColorIndexTeal          6 
acColorIndexViolet        5 
acColorIndexWhite         15 
acColorIndexYellow        11
Both work the same; e.g., MyControl.ForeColor = acColorIndexWhite and MyControl.ForeColor = vbWhite produce the same result. The former just takes less memory.

that's useful. I take it eight are the same, but we get eight more?
 
If you really wanted to get kinky, you can search the web for Excel color codes and find 56 combinations that are pre-defined for Excel (though you can use a custom color there, too.) You can then define a bunch of color constants to match the colors used by spreadsheets. A couple of oddball cases apply because some of those colors repeat (which is why there are only 56 colors, not 64). The repetition is for the automatic colors assigned when doing graphics things.
 

Users who are viewing this thread

Back
Top Bottom