How to converte color value(longint) into RGB value.
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 'Coding Basics - How to converte color value(longint) into RGB value. Public Function rgbcolortovalue(rslt As Long) As String Dim tmphasil1 As Byte Dim tmphasil2 As Byte Dim tmphasil1a As Byte Dim tmphasil1b As Byte Dim tmphasil1c As Long If rslt < 256 Then rgbcolortovalue = Trim(Format(rslt, "0##")) + ",000,000" ElseIf (rslt > 256) And (rslt < 65536) Then tmphasil1 = rslt Mod 256 tmphasil2 = Int(rslt / 256) rgbcolortovalue = Trim(Format(tmphasil1, "0##")) + "," + Trim(Format(tmphasil2, "0##")) + ",000" ElseIf rslt > 65535 Then tmphasil2 = Int(rslt / 65536) tmphasil1c = rslt Mod 65536 If tmphasil1c < 256 Then rgbcolortovalue = Trim(Format(tmphasil1c, "0##")) + ",000," + Trim(Format(tmphasil2, "0##")) Else tmphasil1a = tmphasil1c Mod 256 tmphasil1b = Int(tmphasil1c / 256) rgbcolortovalue = Trim(Format(tmphasil1a, "0##")) + "," + Trim(Format(tmphasil1b, "0##")) + "," + _ Trim(Format(tmphasil2, "0##")) End If End If End Function |