Today I needed a way to convert from VB color format to the hexadecimal HTML format so after 5-10 minutes I came with the code & post below.
Visual Basic stores the color data in the following format : 00BBGGRR so the next logical step to extract the information in the format we need ( #RRGGBB ) is to inverse the red component with the blue component.Simple, right?
Visual Basic
-
Function VB2HTMLColor(color As Long) As String
-
Dim aux As String
-
aux = Right("00000" & Hex(color), 6)
-
VB2HTMLColor = "#" & Right(aux, 2) & Mid(aux, 3, 2) & Left(aux, 2)
-
End Function
Works perfectly. Thanks much.