Hexadecimal String to Color

Hello everybody,

i write color values as attributes to Xml files. The Attribute String looks like this: #RRGGBBAA. Now I wanna read the hexadecimal color string back to a color. How can I do that? I separate the RGBA values via String.Mid(start, length). But I need the integer value of the hex codes.

I don’t wanna use the new Xojo Framework!

Dim s As String = "#01020304" Dim v As Variant = s.Replace("#", "&c") Dim c As Color = v

Or this if you want to get more compact:

Dim s As String = "#01020304" Dim c As Color = CType(s.Replace("#", "&c"), Variant)

Or this, but your input will be a string, so this is a wee bit overkill :wink:

Dim c As Color = CType(CType("#01020304", String).Replace("#", "&c"), Variant)

Or I could actually read your post again and give you what you asked for :wink:

Dim s As String = "#01020304" Dim c As Color = CType(s.Replace("#", "&c"), Variant) Dim r As Integer = c.Red Dim g As Integer = c.Green Dim b As Integer = c.Blue Dim a As Integer = c.Alphae

I need some sleep :smiley: