delphi中怎样将十六进制转为十进制

解决方案 »

  1.   

    function HexToInt(S: String): Integer;
    begin
      result := StrToInt('$' + S);
    end;
      

  2.   

    你在转换一次不久得了?
    IntTostr(StrToInt('$' + S))
      

  3.   

    S := Chr(Inttostr('$'+'D5C5'))
      

  4.   

    {十六进制转换为十进制}
    function HexToInt(const aHex: string): Integer;
    var
      I,L,K: Integer;
    begin
      Result := 0;
      if aHex = '' then Exit;  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;  Result := K;
    end;
      

  5.   

    这么简单的,还需要问?
    S:='A5';
    StrToIntDef('$'+S, 0);http://lysoft.7u7.net
      

  6.   

    记得delphi有个调试功能,输入上面两种进制,可以直接转换的