how does the "BackColor" Long Integer work?

white = 16777215
pink = 13027071
blue = 15977088

(or there abouts)

what i'm asking is, if i want to tweek the shade a little, what's the logic?

i thought it might be RRR GGG BBB but (besides there not being 9 digits) i've been playing with it, and i can't determine any rhyme to it.

for the points, please tell me what digits control what aspects of the color (or a good web site where this information can be found)

thanks,
mac

LVL 4
MacRenaAsked:
Who is Participating?
 
dqmqCommented:
Here's the color constants (in hex) which I believe are additive.  


vbRed         0x0000FF       Red
vbGreen      0x00FF00       Green
vbBlue        0xFF0000       Blue


For example, to Yellow = Red + Green = 0x0000FF + 0x00FF00 = 0x00FFFF

To get less red, subtract n *  (2 ^ 0)  where n = 1 to 255
To get less green, subtract n * (2 ^ 8) where n = 1 to 255
To get less blue, subtract n * (2 ^ 16) where n = 1 to 255
0
 
harfangCommented:
If you want to tweak the colors, use the built-in RGB() function:

    RGB(255,255,255) = 16777215 (white)
    RGB(0,0,255) = 16711680 (blue)
    RGB(255,0,0) = 255 (red)

If you are familiar with Hex notation, you can go:

    .BackColor = &HFFFFFF& (white)
    .BackColor = &H00FF00& (green)
    .BackColor = &H0000FF& (red)

Note however that the VB colors are coded "BGR" (as explained by dqmg) with red = &HFF, unlike the "internet colors" coded "RGB" with red = 0xff0000

And you can also just click the builder button on any "color" property, pick your color in the dialog box and then remember the numeric  value.

Good luck!
(°v°)
0
 
thenelsonCommented:
And you will find a great free tool for tweaking colors (and other things) here:
http://personales.conexion.com.py/sgrillo/
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Gustav BrockCIOCommented:
Here's how to extract the discrete colours:

Public Sub CompositeRGB( _
  ByVal lngRGB As Long, _
  ByRef intRed As Integer, _
  ByRef intGreen As Integer, _
  ByRef intBlue As Integer)
 
' Calculate discrete RGB colours from composite colour value.
'
' 1999-08-20. Cactus Data ApS, CPH
 
  If lngRGB < 0 Then
    ' Nothing to do.
    intRed = 0
    intGreen = 0
    intBlue = 0
  Else
    ' Dissolve composite RGB into discrete colours.
    intRed = lngRGB And vbRed
    intGreen = (lngRGB And vbGreen) / &H100
    intBlue = (lngRGB And vbBlue) / &H10000
  End If
  Debug.Print intRed, intGreen, intBlue

End Sub
0
 
MacRenaAuthor Commented:
thanks everyone.
hmmm, 50 points won't go far.  increasing to split
mac
0
 
harfangCommented:
It was kind of you to increase points and to aknowledge all contributions. Thanks!
(°v°)
0
 
thenelsonCommented:
You're welcome.  Glad to help and thank you very much for the points with "A" grade!  Thanks for the split.

Happy Computing!

Nelson
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.