RGB color

D

Douglas J. Steele

The colour value is actually RGB, but in the reverse order. If you convert
any value back to Hex, you'll see that the first 2 digits are the Blue
value, the middle 2 digits are the Green value and the last 2 digits are the
Red value.

Therefore, the following will work:

Function Red(ColourValue As Long) As Long
Dim strHexColour As String

strHexColour = Right$("000000" & Hex(ColourValue), 6)
Red = CLng("&H" & Right$(strHexColour, 2))

End Function

Function Green(ColourValue As Long) As Long
Dim strHexColour As String

strHexColour = Right$("000000" & Hex(ColourValue), 6)
Green = CLng("&H" & Mid$(strHexColour, 3, 2))

End Function

Function Blue(ColourValue As Long) As Long
Dim strHexColour As String

strHexColour = Right$("000000" & Hex(ColourValue), 6)
Blue = CLng("&H" & Left$(strHexColour, 2))

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top