Does anybody know convert VB ColorCionstant to HTML color code, like
17849940 to #C0C0C0
Printable View
Does anybody know convert VB ColorCionstant to HTML color code, like
17849940 to #C0C0C0
An HTML color code is, I think, a "#" sign followed by three two-character hexadecimal values for the red, green, and blue, and I think that's the right order.
There are plenty of GetRed/GetGreen/GetBlue functions around, and the Hex$ or Hex function will convert from decimal to hexadecimal.
So: HTMLCode$ = "#" & Str(GetRed(myColor)) & Str(GetGreen(myColor)) & Str(GetBlue(myColor))
Just off the top of my head, hope it works!
Thanks. I used Hex function as you suggested. It works now.
No problem. Post if you have more trouble. :)
If you want to use the VB Colour constants (like vbInfoBackground and vbButtonFace), then you need to translate those values to actual RGB values first using the OleTranslateColor API call
- gaffa