D
Douglas J. Steele
Believe it or not, 123456 is RGB, but in the reverse order. If you convert
that value to Hex (01E240), the first 2 digits (Hex 01, or Decimal 1) are
the Blue value, the middle 2 digits (Hex E2, or decimal 226) are the Green
value and the last 2 digits (Hex 40, or Decimal 64) are the Red value.
Try 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
that value to Hex (01E240), the first 2 digits (Hex 01, or Decimal 1) are
the Blue value, the middle 2 digits (Hex E2, or decimal 226) are the Green
value and the last 2 digits (Hex 40, or Decimal 64) are the Red value.
Try 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