function StrtoHex(S: String; AFormat: Integer;formatstring : String): String;
var
  I : Integer ;
  Temp : String ;
begin
  Temp := '';
  if s = '' then StrtoHex := '' else
  begin
     For I := 1 to Length(s) do
     begin
          temp := Temp + formatstring +InttoHex(Ord(s[i]),Aformat);
     end ;
  end ;
  Strtohex := temp ;
end;

解决方案 »

  1.   

    function StrToByte(A:string):byte
    begin
    ??????????????????
    end;
    HELP ME...
      

  2.   

    使用时:StrtoHex(S: String{要转换的字符串}; AFormat: Integer{每个16进值的长度};formatstring : String{每个16进值的间隔符}): String如: s := '1234'  StrtoHex (s,2,'');则为‘31323334’
                      StrtoHex (s,2,'0X');则为‘0X310X320X330X34’
                      StrtoHex (s,3,'');则为‘031032033034’
      

  3.   

    function StrToByte(A:string):byte
    begin
    ??????????????????
    end;
    __________________
    什么意思?将字符串转换成Byte?ord():返回一个字符的ASCII值(整数)
    Inttohex:将整形的16进制返回为字符串
      

  4.   

    是的 生成的16进制 要转换成BYTE
      

  5.   

    function  StrToByte(A:string):byte就不对了应该是
    function  StrToByte(A:char):byte呀
    好办了
    function  StrToByte(A:char):byte
    begin
    StrToByte := strtoint(InttoHex(Ord(c),2));
                
    end ;
      

  6.   

    写错了,应该是
    function    StrToByte(A:char):byte
      begin
      StrToByte  :=  strtoint(InttoHex(Ord(A),2));
                              
      end  ;
      

  7.   

    给你两个函数
    function HexToDec(HexData: Integer): Integer;
    var m: Integer;
    begin
      Result := 0;
      m := Trunc(Power(10, Length(IntToStr(HexData)) - 1));
      while m > 0 do
      begin
        Result := (Result*16 + HexData div m);
        HexData := HexData mod m;
        m := m div 10;
      end;
    end;function DecToHex(DecData: Integer): Integer;
    var m: Integer;
    begin
      Result := 0;
      m := Trunc(Power(16, Length(IntToStr(DecData)) - 1));
      while m > 0 do
      begin
        Result := (Result*10 + DecData div m);
        DecData := DecData mod m;
        m := m div 16;
      end;
    end;
      

  8.   

    function  HexStrtoInt(var Buf: string): dword;
    //将十六进制的字符串转成整型
      //判断是否是十六进制数
      function IsHexChar(Chr: char): boolean;
      begin
        Result := (Chr in ['0'..'9']) or (Chr in ['A'..'F']);
      end;
      //将一个十六进制字符转换成数
      function HexChrtoInt(Chr: char): byte;
      begin
        Result := 0;
        case Chr of
          '0'..'9' : Result := Strtoint(Chr);
          'A'      : Result := 10;
          'B'      : Result := 11;
          'C'      : Result := 12;
          'D'      : Result := 13;
          'E'      : Result := 14;
          'F'      : Result := 15;
        end;
      end;
    var
      BufLength: dword;
      TempBuf: string;
      Count0: dword;
    begin
      Result := 0;
      BufLength := Length(Buf);
      TempBuf := '';
      if BufLength > 0 then begin
        Buf := Uppercase(Buf);
    //    for Count0 := 1 to BufLength
        if BufLength mod 2 = 1 then begin
          Buf := '0' + Buf;
          BufLength := Length(Buf);
        end;
        for Count0 := 1 to BufLength div 2 do
          if IsHexChar(Buf[Count0 * 2 - 1]) then begin
            if IsHexChar(Buf[Count0 * 2]) then begin
              TempBuf := TempBuf + inttostr(HexChrtoInt(Buf[Count0 * 2 - 1]) * 16 + HexChrtoInt(Buf[Count0 * 2]));
            end else begin
              Result := Count0 * 2;
              Break;
            end;
          end else begin
            Result := Count0 * 2 - 1;
            Break;
          end;
        if Result = 0 then Buf := TempBuf;
      end;
    end;
      

  9.   

    hexstring:=format('%0x',DecValue);
    这么简单,还不试试!