VB Express Color Object to Hex String


This function takes a color object and returns the Hex value with a preceeding #.

Private Function ColorHex( ByVal color As Color) As String
        Dim r As String = Hex(FColor.R), G As String = Hex(FColor.G), B As String = Hex(FColor.B)
        If r.Length = 1 Then r = 0 & r : If G.Length = 1 Then G = 0 & G : If B.Length = 1 Then B = 0 & B
        ColorHex = "#" & r & G & B
End Function

You might also like...


Chris Buske


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“A computer lets you make more mistakes faster than any other invention in human history, with the possible exceptions of handguns and tequila” - Mitch Ratcliffe