A bit about colors
I came up with this little piece of code for an app. that I'm currently writing. The requirement was that a user can specify colors in an app. configuration file in either named or Hex format. I also used this a *lot* while building the app.
<-- code marked-up with toolX -->darkColorName = CStr(doc.SelectSingleNode("/Units/ColorSchema").Attributes("darkBgColor").Value) '. '. '. Try If Microsoft.VisualBasic.Left(darkColorName, 1) = "#" Then darkColorName = ColorStringFromHexString(darkColorName) Me.DarkColor = Drawing.Color.FromArgb( _ CType(Mid(darkColorName, 1, 2), Byte), _ CType(Mid(darkColorName, 3, 2), Byte), _ CType(Mid(darkColorName, 5, 2), Byte) ) Else Me.DarkColor = Drawing.Color.FromName(darkColorName) End If Catch ex As System.ArgumentException ' named colors not provided or inaccurate Me.DarkColor = Drawing.Color.FromName("Desktop") End Try '. '. '. '. Private Function ColorStringFromHexString(ByVal hexStrng As String) As String If Microsoft.VisualBasic.Left(hexStrng, 1) = "#" Then hexStrng = Mid(hexStrng, 2) End If Return "" & CLng("&H" & hexStrng) End Function