Try using a
Dictionary
keyed on the
Color
, where the value is either the
MyColor
class or just the
ID
value.
Dim allMyColors As Dictionary(Of Color, Integer) = New Dictionary(Of Color, Integer)()
...
Dim id As Integer
Dim key As Color = Color.FromArgb(R, G, B)
If allMyColors.TryGetValue(key, id) Then
Return id
Else
Return 0
End If