### Convert hex color to RGB

Simple conversion formula
Lotus Formula

```REM "Converts #FFFFFF to 255,255,255";

R1 := @uppercase(@Right(@Left(hex;2);1));
R2 := @uppercase(@Right(@Left(hex;3);1));
G1 := @uppercase(@Right(@Left(hex;4);1));
G2 := @uppercase(@Right(@Left(hex;5);1));
B1 := @uppercase(@Right(@Left(hex;6);1));
B2 := @uppercase(@Right(hex;1));

alpha := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9" : "A" : "B" : "C" : "D" : "E" : "F" ;
numeric := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9" : "10" : "11" : "12" : "13" : "14" : "15" ;

R1 := @Replace(R1; alpha ; numeric );
R2 := @Replace(R2; alpha ; numeric );
G1 := @Replace(G1; alpha ; numeric );
G2 := @Replace(G2; alpha ; numeric );
B1 := @Replace(B1; alpha ; numeric );
B2 := @Replace(B2; alpha ; numeric );

R := @Text((@TextToNumber(R1)*16)+(@TextToNumber(R2)));
G := @Text((@TextToNumber(G1)*16)+(@TextToNumber(G2)));
B := @Text((@TextToNumber(B1)*16)+(@TextToNumber(B2)));

```

DISPLAY ONLY

`R + ", " + G + ", " + B`

DISPLAY AND SORT IN NUMERICAL ORDER

```Rsort := @If(@Length(R)=1; "00" + R ; @Length(R)=2 ; "0" + R ; R);
Gsort := @If(@Length(G)=1; "00" + G ; @Length(G)=2 ; "0" + G ; G);
Bsort := @If(@Length(B)=1; "00" + B ; @Length(B)=2 ; "0" + B ; B);

"" + R + ", " + G + ", " + B```

Written by Frank Joseph Brefere III

Posted by fbrefere001 on Tuesday March 31, 2009