Convert Hexadecimal -> Integer  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 02/08/99

Tip accessed 473 times

 



 function HexToInt(const Value: String): Integer;
 begin
   Result := StrToInt('$' + Value);
 end;



A call example:


     Label1.Caption:=IntToStr( HexToInt('FF') );




Another function:


 function HextoInt(HexStr:string):integer;
 CONST Hex : array['A'..'F'] of integer = (10,11,12,13,14,15);
 var
     i   : integer;
 begin
   Result:=0;
   for i := 1 to Length(HexStr) do
     if HexStr[i] < 'A' then Result := Result * 16 + Ord(HexStr[i]) - 48
                        else Result := Result * 16 + Hex[HexStr[i]];
 end;