# change hex color to ligher or darker

I need some kind of function that can i change a hex color to lighter or darker.

Example:
------------------------

strColor = LightenColor("#000000", 50)
strColor2 = LightenColor("#FFFFFF", 25)

Function LightenColor(strHex, strValue)
'strHex holds the color
'strValue holds how much to change
'Code to lighten color
End Function

Function DarkenColor(strHex, strValue)
'strHex holds the color
'strValue holds how much to change
'Code to lighten color
End Function
------------------------

###### Who is Participating?

Commented:
Something along these lines ... intPercentage can be a positive number to lighten and negative to darken:

Function LightenDarken(intR, intG, intB, intPercent)
Dim r : r = Int((intR * intPercent) / 100)
Dim g : g = Int((intG * intPercent) / 100)
Dim b : b = Int((intB * intPercent) / 100)
If r > 255 Then r = 255
If g > 255 Then g = 255
If b > 255 Then b = 255
If r < 0 Then r = 0
If g < 0 Then g = 0
If b < 0 Then b = 0
r = Hex(r)
g = Hex(g)
b = Hex(b)
If Len(r) = 1 Then r = "0" + r
If Len(g) = 1 Then g = "0" + g
If Len(b) = 1 Then b = "0" + b
LightenDarken = r + g + b
End Function
0

Author Commented:
thanks, had to edit it a bit but that works.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.