Mike Krailo
Well-known member
- Local time
- Today, 06:19
- Joined
- Mar 28, 2020
- Messages
- 1,681
My current project requires some user defined colors to be entered into the form. The form allows for the generation of custom reports. These colors adjust a Reports title font and some other controls as well. The problem that I need to solve is how to take any of those colors entered and calculate the lightest shade that can be produced for that given color. This calculated value will be used to set the back color of the RptTitle control on the report based on the entered color for the Border of that same control. This allows the user to enter just two base colors to which other shades are calculated and set on other controls.
Hope that makes sense.
The colors are entered via a text box with a value like "#F67912". I have a function that converts that to the Decimal value of 1210870. Now I want another function that takes that value 1210870 and converts it to 16251903 which is close to the lightest shade of that original color. What's the best way to go about this?
Here is my function for doing the basic hex to decimal conversion:
Update: Just changed the title from HUE to Luminosity since that is more what I really meant.
Hope that makes sense.
The colors are entered via a text box with a value like "#F67912". I have a function that converts that to the Decimal value of 1210870. Now I want another function that takes that value 1210870 and converts it to 16251903 which is close to the lightest shade of that original color. What's the best way to go about this?
Here is my function for doing the basic hex to decimal conversion:
Code:
Public Function HexToDec(HexCode As String) As Long
Dim Red As String
Dim Green As String
Dim Blue As String
Dim NewHex As String
NewHex = Right(HexCode, 6) 'strips the octothorp if there is one
Red = Left(NewHex, 2)
Green = Mid(NewHex, 3, 2)
Blue = Right(NewHex, 2)
HexToDec = RGB("&H" & Red, "&H" & Green, "&H" & Blue)
End Function
Update: Just changed the title from HUE to Luminosity since that is more what I really meant.
Last edited: