Darken color (1 Viewer)

smig

Registered User.
Local time
Today, 11:36
Joined
Nov 25, 2009
Messages
2,209
How can I darken a color by 20%, using VBA ?
Can I convert, using VBA, an existing color into it's HSL value ?
 

Tieval

Still Clueless
Local time
Today, 09:36
Joined
Jun 26, 2015
Messages
475
I don't think you can darken a colour by 20% but you can change a colour to a colour value that is 20% darker.

Attribute an RGB colour to it and when you want it to change make it a different RGB colour. HSL to RGB pickers are available all over the internet.
 

smig

Registered User.
Local time
Today, 11:36
Joined
Nov 25, 2009
Messages
2,209
Thanks
I solved it by saving the rgb color in the tag. From there I know how to darken it.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:36
Joined
Sep 12, 2006
Messages
15,613
I imagine reducing each of the rgb values by the same percentage will darken a colour without changing the "tone", if that is the right word.
 

smig

Registered User.
Local time
Today, 11:36
Joined
Nov 25, 2009
Messages
2,209
I imagine reducing each of the rgb values by the same percentage will darken a colour without changing the "tone", if that is the right word.
This is exactly what I do.
Problem Access native color system is not RGB.
I save the RGB value in the Tag property and go from there.
Is there an easy way to convert the Access color into RGB ?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 09:36
Joined
Sep 12, 2006
Messages
15,613
took ages to find where I had put it ....

Code:
 Function analyseRGB(col As Long) As String
Dim r As Long
Dim g As Long
Dim b As Long
Dim q As Long
r = col Mod 256
q = Int(col / 256)
g = q Mod 256
b = Int(q / 256)
analyseRGB = r & "," & g & "," & b

 'MsgBox ("Red: " & r & vbCrLf & _
    "Green: " & g & vbCrLf & _
    "Blue: " & b & vbCrLf)
 
End Function
 

Minty

AWF VIP
Local time
Today, 09:36
Joined
Jul 26, 2013
Messages
10,353
I'm sure I used to have a database I downloaded somewhere that did all the hard work - but can't find it.
This site is handy http://endprod.com/colors/

edit - actually this site is where I got the colour picker db from :)
 

smig

Registered User.
Local time
Today, 11:36
Joined
Nov 25, 2009
Messages
2,209
I made my oun color picker.
you can find it here: Color picker

What I realy needed now is the part of code Dave gave to convert the Access color into RGB.
It's easy to Darken/Lighten it once I have it as RGB.
 

Users who are viewing this thread

Top Bottom