O As Single
Dim hN As Single, sN As Single, lN As Single
Dim hErr As Single, sErr As Single, lErr As Single
   
   lMinER = 255: lMinEB = 255: lMinEG = 255
   'hErr = 10: sErr = 10: lErr = 10
   'RGBToHLS Red, Green, Blue, hO, sO, lO
   'hO = hO + 1 ' hue runs -1 to 5
  '
   'For i = 1 To m_iPalette
   '   With m_tPal(i)
   '      If (Red = .Red) And (Blue = .Blue) And (Green = .Green) Then
   '         ClosestIndex = i
   '         Exit Property
   '      Else
   '         RGBToHLS .Red, .Green, .Blue, hN,