Format Color for HTML

This function, which converts a color value into a string suitable for HTML, formats an RGB color value, palette index, or system color constant. You accomplish this by breaking out the individual color values for red, green, and blue, then recombining them in the opposite order Windows likes, so HTML renderers will provide the correct color. The call to OleTranslateColor ensures you’re using an actual color reference, by dereferencing system color constants or palette indices:

Public Function HtmlHexColor(ByVal ColorValue As _	Long) As String	Dim r As Byte	Dim g As Byte	Dim b As Byte	' convert color if needed	Call OleTranslateColor( _		ColorValue, 0&, ColorValue)		' break out color bytes	r = (ColorValue Mod &H100)	g = (ColorValue  &H100) Mod &H100	b = (ColorValue  &H10000) Mod &H10000	' format the return string	HtmlHexColor = "#" & _		Right$("0" & Hex$(r), 2) & _		Right$("0" & Hex$(g), 2) & _		Right$("0" & Hex$(b), 2)End Function
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS