有没有什么函数可以将十六进制的字符串转成十进制的呢?
或者二进制转成十进制

解决方案 »

  1.   

    function HexToInt(s:string):integer;
    begin
      Result:=StrToInt('0x'+s);
    end;2->10的就慢慢乘上去啊
      

  2.   

    Converts a string that represents an integer (decimal or hex notation) to a number.UnitSysUtilsCategorytype conversion routinesDelphi syntax:function StrToInt(const S: string): Integer;C++ syntax:extern PACKAGE int __fastcall StrToInt(const AnsiString S);DescriptionStrToInt converts the string S, which represents an integer-type number in either decimal or hexadecimal notation, into a number. If S does not represent a valid number, StrToInt raises an EConvertError exception.
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Edit1: TEdit;
        Edit2: TEdit;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      i: integer;
    begin
      i := StrToInt('$'+Edit1.Text);
      Edit2.Text := IntToStr(i);
    end;end.
      

  4.   

    十六进制和十进制没有本质的区别,不过在DELPHI中十六进制FF就是十进制的255,为显示直观,可以将其表示为十六进制的字符串:   INTTOHEX(255,2)//返回字符串:FF要想转换回去就得用
        
       StrToInt('$'+'FF');方法了。'$'是十六进制标志,和一些语言中的0XFF 、 FFH 等表示方法等效,只是DELPHI中用$.注意:StrToInt('$'+'FF');如果提供的字符串非法,转换将失败。