how can i change the decimal colors returned by the color dialog into colors like 255,255,255?
Printable View
how can i change the decimal colors returned by the color dialog into colors like 255,255,255?
Hello sailbrdr,
Try this source:
Dim Str As String
Dim N As Integer
Dim Rdec, Gdec, Bdec As Single
Dim Rhex, Ghex, Bhex As String
'N is the variable to convert
N = Val("&H" + "fF")
Str = Right("00000" + Hex(N), 6)
Rhex = "&H" + Left(Str, 2)
Rdec = Val(Rhex)
Ghex = "&H" + Mid(Str, 3, 2)
Gdec = Val(Ghex)
Bhex = "&H" + Right(Str, 2)
Bdec = Val(Bhex)
Good luck,
Michelle
What about going back?
Test this
Dim iR as Integer
Dim iG as Integer
Dim iB as Integer
Dim sRHex as String
Dim sGHex as String
Dim sBHex as String
If Len(Hex(iR)) < 2 Then
sRHex = "0" & Hex(iR)
Else
sRHex = Hex(iR)
End If
If Len(Hex(iG)) < 2 Then
sGHex = "0" & Hex(iG)
Else
sGHex = Hex(iG)
End If
If Len(Hex(iB)) < 2 Then
sBHex = "0" & Hex(iB)
Else
sBHex = Hex(iB)
End If
Maybe this:
Dim N As Long
Dim Rdec, Gdec, Bdec As Single
Dim Rhex, Ghex, Bhex As String
Dim STR As String
'N is the variable to convert
N = Val("&H" + "FF01FF")
STR = Right("00000" + Hex(N), 6)
Rhex = "&H" + Left(STR, 2)
Rdec = Val(Rhex)
Ghex = "&H" + Mid(STR, 3, 2)
Gdec = Val(Ghex)
Bhex = "&H" + Right(STR, 2)
Bdec = Val(Bhex)
Rhex = Trim(Left(STR, 2))
Ghex = Trim(Mid(STR, 3, 2))
Bhex = Trim(Right(STR, 2))
'------------------------------------------
Rhex = Right(("0" + Rhex), 2)
Ghex = Right(("0" + Ghex), 2)
Bhex = Right(("0" + Bhex), 2)
N = Val("&H" + Rhex + Ghex + Bhex)
Good luck,
Michelle.
Thanks a bunch