Not bad. Perhaps:
Function HexStringFromColor(ByVal Colore As Color) As String
Return "#" & Colore.ToArgb().ToString("X").Substring(2)
End Function
The ToArgb() method returns a 32-bit number containing the A,R,G, and B
components of the color. The Int32.ToString(string) method converts an Int32
to a string using the format string provided. The "X" format string converts
the Int32 to a string representation of hexadecimal notation for the number.
And the Substring() removes the Alpha hex value from the string.
But it isn't much more succinct than yours. I don't think it can be.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Big things are made up of
lots of little things.
<ex********@libero.it> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
To conver a color to its hexadecimal string I have devised
this way:
Function HexStringFromColor(ByVal Colore As Color) As String
Return "#" & Colore.FromArgb(Colore.A,
Colore).Name.Substring(2).ToUpper
End Function
but it seems a little bit ackward. I would like to ask if there
is a better way (colortranslator does not seem to have this function,
but I may be missing it).
-Pamela