We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

how does the "BackColor" Long Integer work?

MacRena
MacRena asked
on
Medium Priority
243 Views
Last Modified: 2008-02-26
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

Comment
Watch Question

Commented:
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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Commented:
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°)
CERTIFIED EXPERT
Commented:
And you will find a great free tool for tweaking colors (and other things) here:
http://personales.conexion.com.py/sgrillo/
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
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

Author

Commented:
thanks everyone.
hmmm, 50 points won't go far.  increasing to split
mac

Commented:
It was kind of you to increase points and to aknowledge all contributions. Thanks!
(°v°)
CERTIFIED EXPERT

Commented:
You're welcome.  Glad to help and thank you very much for the points with "A" grade!  Thanks for the split.

Happy Computing!

Nelson
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.