In HTML colors are specified by indicating the three color
components that make up the color desired.
These are Red, Green, and Blue and are specified using
their hexadecimal values from 0 (00) to 255 (FF).
Color attributes follow this general form:
where RR is the red component, GG is the green component, and BB
is the blue component of the specified color.
VBScript comes with the built in Hex function to convert decimal
values to this hexadecimal form. For example:
<%= Hex(255) %>
will return FF which you could then use as any of the
color components of an HTML color attribute.
But what if you need to convert from the hexadecimal values
to the standard decimal ones used by so many paint and
drawing programs? There's really no function to do it built into VBScript.
The reason there's no function for it is that you really
don't need one. Hexadecimal numbers are represented as
numbers prefixed by "&H" and if you ask VBScript to give you
their value, it'll automatically convert them to decimal form.
<%= &HFF %>
will return 255 without you doing anything at all. The real
problem arises when you read that value in from somewhere. Most values
that contain alphanumeric characters will come into VBScript as variants
of sub-type string. Luckily it's solved easily enough. Simply pre-pend the
"&H" I mentioned earlier and then convert to a numeric type and
VBScript will figure everything out for you. While: