به مبناي 10 تبديل كن. و كارت رو انجام بده . دوباره برگردون مبناي دلحواه
براي تبديل به مبناي ده مي توني كلك بزني
function HexToInt(HexNum: string): LongInt;
begin
Result:=StrToInt('$' + HexNum) ;
end;
اينم بر عكس
unit HexConvert;
interface
uses SysUtils;
function HexTo(Value: string): Longword;
function ToHex(Value: Byte): string; overload;
function ToHex(Value: Word; Splitter: Char): string; overload;
function ToHex(Value: Cardinal; Splitter: Char): string; overload;
implementation
const
HexTbl: string = '0123456789ABCDEF';
function HexTo(Value: string): Longword;
var
intX, PosCnt: Byte;
zwVal: Integer;
begin
Result := 0;
PosCnt := 0;
for intX := Length(Value) - 1 downto 0 do
begin
zwVal := Pos(UpperCase(Value[intX + 1]), HexTbl) - 1;
if zwVal >= 0 then
begin
Result := Result + (zwVal shl (4 * PosCnt));
Inc(PosCnt);
end;
end;
end;
function ToHex(Value: Byte): string;
var
zwVal: Byte;
begin
zwVal := (Value and $0F);
Result := HexTbl[zwVal + 1];
zwVal := (Value and $F0) shr 4;
Result := HexTbl[zwVal + 1] + Result;
end;
function ToHex(Value: Word; Splitter: Char): string;
begin
Result := ToHex(Byte(Lo(Value)));
Result := ToHex(Byte(Hi(Value))) + Splitter + Result;
end;
function ToHex(Value: Cardinal; Splitter: Char): string;
var
zwVal: Word;
begin
zwVal := Value and $0000FFFF;
Result := ToHex(Word(zwVal));
zwVal := (Value and $FFFF0000) shr 16;
Result := ToHex(Word(zwVal)) + Splitter + Result;
end;
end.