delphi中有直接把10进制转换成16进制的函数:
function IntToHex(Value: Integer; Digits: Integer): string; overload;
function IntToHex(Value: Int64; Digits: Integer): string; overload;
使用方法为:
procedure TForm1.Button1Click(Sender: TObject); var i,m: Integer; begin Label1.Caption := ''; for i := 1 to Length(Edit1.Text) do begin m := StrToInt(Edit1.Text[i])); edit2 := IntToHex(StrToInt(Edit1.Text[i]),2)+ ''; edit3 := IntToHex(m,2); end; end;
十六进制转十进制
I := StrToInt('$' + '64');