Public Function ToColorFromTitleCaseLetters(ByVal fullName As String) As Color
If fullName.IsNullOrEmpty() Then
Return Color.Blue
End If
Try
Dim result As String = String.Concat(Regex.Matches(fullName, "[A-Z]").OfType(Of Match)().Select(Function(match) match.Value))
Dim hash As Integer = 1
If result.Length > 1 Then
hash = (Convert.ToInt32(result.Chars(0)) - 64) * 100 + Convert.ToInt32(result.Chars(1)) - 64
'https://stackoverflow.com/questions/14204827/ms-chart-for-net-predefined-palettes-color-list
Dim colors() As String = { "008000", "0000FF", "800080", "800080", "FF00FF", "008080", "FFFF00", "808080", "00FFFF", "000080", "800000", "FF3939", "7F7F00", "C0C0C0", "FF6347", "FFE4B5", "33023", "B8860B", "C04000", "6B8E23", "CD853F", "C0C000", "228B22", "D2691E", "808000", "20B2AA", "F4A460", "00C000", "8FBC8B", "B22222", "843A05", "C00000" }
Dim max As Integer = ((AscW("Z"c) - 64) * 100 + AscW("Z"c) - 64)
Dim index As Decimal = (CDec(hash) / CDec(max)) * colors.Length
Return Color.FromHex(colors(CInt(Math.Truncate(index))))
End If
Catch
End Try
Return Color.Blue
End Function