Try this one:
function HexToInt2(s: string): Int64;
var
b: Byte;
c: Char;
begin
Result := 0;
s := UpperCase(s);
for b := 1 to Length(s) do
begin
Result := Result * 16;
c := s[b];
case c of
'0'..'9': Inc(Result, Ord(c) - Ord('0'));
'A'..'F': Inc(Result, Ord(c) - Ord('A') + 10);
else
raise EConvertError.Create('No Hex-Number');
end;
end;
end;
Main Topics
Browse All Topics





by: GreybirdPosted on 2005-07-05 at 12:56:09ID: 14372518
You should try :
function hexaToInt(s : string) : Int64;
begin
if (s <> '') and (s[1] <> '$') then
result := strToInt64('$' + s)
else
result := strToInt64(s);
end;