Hi,
I was just wondering if there is a way to convert a VB color code to html color code ?
Thanks
Printable View
Hi,
I was just wondering if there is a way to convert a VB color code to html color code ?
Thanks
Vb color code is a decimal value stored in a long and html is a hex value stored in a string. just convert between them using
Code:htmlcolor = Hex(vbcolor)
Hi Kedaman,
R U Sure? I try That and it is not the same.
HtmlColor = hex(vbred)
???
Code:Public Function FormatRGBString(val As Long) As String
Dim color As String
Dim pad As Long
Dim r As String
Dim g As String
Dim b As String
' This function formats a long consisting of rgb values
' taken from the CommonDialog color dialog
' to a string in the form of "#RRGGBB" where RRGGBB are
' hex values
' convert to hex
color = Hex(val)
'determine how many zeros to pad in front of converted value
pad = 6 - Len(color)
If pad Then
color = String(pad, "0") & color
End If
'Extract the rgb components
r = Right(color, 2)
g = Mid(color, 3, 2)
b = Left(color, 2)
' Swab r and b position, color dialog returns
' bgr instead of rgb
color = "#" & r & g & b
FormatRGBString = color
End Function