Converting HTML Colour to RGB

Converting HTML Colour to RGB

Lets say we have a webbrowser and we want to convert the background colour to RGB and VB, here’s how to do it! (webbrowser1.document.bgcolor will return “#aaffff” or similar)
a = Webbrowser1.document.bgColor
R = Val("&H" + Mid$(a$, 2, 2)) ' Value 170
G = Val("&H" + Mid$(a$, 4, 2)) ' Value 255
B = Val("&H" + Mid$(a$, 6, 2)) ' Value 255

result = rgb(R,G,B)

' result is a vb color value (LONG) = 16777130

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.