 |  |  | Home Search What's New Index Books Links Q & A Newsletter Banners Feedback Tip Jar |  |  |  | | | | MSDN Visual Basic Community | | | | | |  | | | | | | | | | Title | Convert HTML colors to and from Visual Basic colors | | Keywords | Web color, HTML color, color, VB color | | Categories | Graphics, Utilities | | | By Kreangsak. HTML colors are written in the format RRGGBB. Visual Basic colors are stored with the blue value in the most significant bits: BBGGRR. The functions in this program use InStr to rearrange the hexadecimal digits to convert from one system to the other. | | Private Function CvtColorVB2Web(colorcode As String) As _ String Dim vcolor vcolor = Hex(Val(colorcode)) If Len(vcolor) < 6 Then vcolor = String(6 - Len(vcolor), "0") & vcolor End If CvtColorVB2Web = Mid(vcolor, 5, 2) & Mid(vcolor, 3, 2) _ & Mid(vcolor, 1, 2) End Function Private Function CvtColorWeb2VB(colorcode As String) As _ String If Len(colorcode) < 6 Then colorcode = colorcode & String(6 - Len(colorcode), _ "0") End If CvtColorWeb2VB = "&H" & Mid(colorcode, 5, 2) & _ Mid(colorcode, 3, 2) & Mid(colorcode, 1, 2) End Function | | |