ANStrColor2RGB + RGB2ANStrColor

Converts R:G:B into RGB value (as long) and RGB from long into R:G:B

Function ANStrColor2RGB(ANStrColor)
' ANStrColor = "146:235:232" (RRR:GGG:BBB)
ANStrColor2RGB = RGB( _
CInt(CutString3(ANStrColor, 1, ":")), _
CInt(CutString3(ANStrColor, 2, ":")), _
CInt(CutString3(ANStrColor, 3, ":")) _
)
End Function
Function RGB2ANStrColor(sLong as long)
' Converts Long to RGB
' Output = RRR:GGG:BBB
' Based on the formula ... RGB = Red + (Green*256) + (Blue*256*256)
 sBlue = sLong \ 65536
 sGreen = (sLong - sBlue * 65536) \ 256
 sRed = sLong - (sBlue * 65536) - (sGreen * 256)
 RGB2ANStrColor = sRed & ":" & sGreen & ":" & sBlue
End Function

ANStrColor
or
sLong

Views 482 Downloads 141

'CutString3', 'RGB', 'ANStrColor', 'colors', 'ANString', 'ANStrList'

ANmarAmdeen
324
Graphics VBA
Revisions

v1.0