Hi VB Programmer,
Sorry, I just realized I gave you the code in C#. It sounds like you
aren't having any problems translating, but just in case:
Public Shared Function ColorToHex(ByVal R As Integer, _
ByVal G As Integer, ByVal B As Integer) As String
Dim red, blue, green As String
red = R.ToString("X2")
green = G.ToString("X2")
blue = B.ToString("X2")
Return "#" & red & green & blue
End Function
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
VB Programmer said:
Thanks everyone! You all rock!
Kevin Spencer said:
Hi VB Programmer,
First, you won't be able to use Alpha in an HTML document, so forget
about that part. As for creating a hexadecimal number from an RGB value,
here's a method I created that does this:
public static string ColorToHex(int R, int G, int B)
{
string r, g, b;
r = R.ToString("X2");
g = G.ToString("X2");
b = B.ToString("X2");
return "#" + r + g + b;
}
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
How do I convert the following to a HEX code I can use in HTML
documents?
1. [A=255, R=0, G=0, B=192]
2. Aqua
FYI: When I print the session variable I'm storing this color in (in
the Immediate window) I get this:
? session("MyBackgroundColor")
"Color [A=255, R=0, G=0, B=192]" {String}
String: "Color [A=255, R=0, G=0, B=192]"
Thanks!