Bootstrap

DELPHI 7 十六進制轉換十進制

DELPHI7 測試通過。

DELPHI 7 十六進制轉換十進制(16進制轉換10進制)

function HexToInt(const aHex: string ):Integer;
var
I,L,K: Integer;
begin
Result := 0 ;
if aHex ='' then
begin
Exit;
end
else
begin
K := 0;
L := Length(aHex);
for I:=1 to L do
begin
if (not(aHex[I] in['A'..'F'])) and (not(aHex[I] in['a'..'f'])) then
K := K + Trunc(StrToInt(aHex[I]) * Power(16, L-I))
else case aHex[I] of
'a', 'A' : K := K + Trunc(10 * Power(16, L-I));
'b', 'B' : K := K + Trunc(11 * Power(16, L-I));
'c', 'C' : K := K + Trunc(12 * Power(16, L-I));
'd', 'D' : K := K + Trunc(13 * Power(16, L-I));
'e', 'E' : K := K + Trunc(14 * Power(16, L-I));
'f', 'F' : K := K + Trunc(15 * Power(16, L-I));
end;
end;
end;
Result := k;
end;
FROM:NETWORK

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/729024/viewspace-1033095/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/729024/viewspace-1033095/

;