How dark is a color
This function seems to work very well:
Function GetContrastingFont(lClr As Long) As Long
'returns a contrasting font colour, given a long colour
'------------------------------------------------------
Dim R As Long
Dim G As Long
Dim B As Long
B = Int(lClr / 65536)
G = Int((lClr Mod 65536) / 256)
R = Int(lClr Mod 256)
'calculation from Peter Thornton
'-------------------------------
If R * 0.206 + G * 0.679 + B * 0.115 135 Then
GetContrastingFont = vbBlack
Else
GetContrastingFont = vbWhite
End If
End Function
RBS
"Paul" wrote in message
...
How do I ascertain how dark a selected color is ?
I want to amend the font color of a form to complement the backcolor
selected by the user - i.e. white font on dark backgrounds, black font on
light backgrounds
|