Convert HTML Color code to Access Color Code

M

Malcolm Hind

I have HTML color codes stored in a DB - like '0000FF' (I
don't store the '#').

I want to set the Box.BackColor fill color of a rectangle to
the HTML color in an access database (rectangle is displayed
on a form) - I cannot find a way to get a color code from the
HTML code that Access can recognize ?

Any help appreciated.

Thanks
 
D

Douglas J. Steele

Function ConvertHTMLColor(HTMLColor As String) As Long
Dim strRed As String
Dim strGreen As String
Dim strBlue As String

If Len(HTMLColor) <> 6 Then
MsgBox HTMLColor & " is invalid."
Else
strRed = "&H" & Left$(HTMLColor, 2)
strGreen = "&H" & Mid$(HTMLColor, 3, 2)
strBlue = "&H" & Right$(HTMLColor, 2)
ConvertHTMLColor = RGB(CInt(strRed), CInt(strGreen), CInt(strBlue))
End If

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