RGB

Return a Long whole number representing an RGB color value.

Syntax
      RGB (red,green,blue)

Key
   red    Red component Variant(integer) 0-255
   green  green component Variant(integer) 0-255
   blue   blue component Variant(integer) 0-255

Examples

Convert a hex-format color to RGB Long:

Function HexToLongRGB(strHexVal As String) As Long
    Dim intRed As Integer
    Dim intGreen As Integer
    Dim intBlue As Integer

    intRed = CLng("&H" & Left$(strHexVal, 2))
    intGreen = CLng("&H" & Mid$(strHexVal, 3, 2))
    intBlue = CLng("&H" & Right$(strHexVal, 2))

    HexToLongRGB = RGB(intRed, intGreen, intBlue)

End Function

The RGB() function can be used to create variables representing all the standard named CSS colours.

“You take the blue pill - the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill - you stay in Wonderland and I show you how deep the rabbit-hole goes” ~ The Matrix

Related:

Syntax - color - Convert RGB to Microsoft Access colour codes.
Average (mix) colours - EMW3


 
Copyright © 1999-2024 SS64.com
Some rights reserved