数据是四字符 '1243' , 转化成 0x12,0x43, 再转化为 两字符的串
这段程序怎么写?
大虾我该怎么写啊,在线等待!

解决方案 »

  1.   

    str := '1234';  ShowMessage('0x' + Copy(str, 1, 2) + '0x' + Copy(str, 3, 2))
      

  2.   

    Chr(StrToInt('&' + Copy(str, 1, 2)))
      

  3.   

    错了,是
    Chr(StrToInt('$' + Copy(str, 1, 2)))
      

  4.   

    先取出12,进行16进制运算,依次类推啦……
    var
       str,Strsub:String;
       strR:String;//存放结果
       i:integer;
    begin
       str:='1234';
       strR:='';
       strsub:=copy(str,1,2);
       Str:=Copy(Str,3,Length(Str)-2);
       while strsub<>'' do
       begin
          i:=strtoInt(Copy(strsub,1,1))*16+StrToInt(Copy(strsub,2,1));
          StrR:=StrR+Chr(i);
          strsub:=copy(str,1,2);
          Str:=Copy(Str,3,Length(Str)-2);
       end;
    end;
      

  5.   

    同意  vuen(不要死,也不要孤独地生活)
      

  6.   

    你问的问题到底是什么???StrToInt('0x12')可以得到Integer值。
      

  7.   

    用copy分离!
    有问题请发信息到我的E-mail:[email protected]
      

  8.   

    我是这样写的,谢谢各位,我这就给分
    function CompactData(strText : string) : string;
    var
       strR,strSrc,strSub:String;
       i:integer;begin
       strSrc:= strText;   strR := '';
       strSub := copy(strSrc,1,2);
       strSrc := Copy(strSrc,3,Length(strSrc)-2);   while strSub <>'' do
       begin
          //get one  char of the  compact result  data
          i:=StrToInt(Copy(strSub,1,1))*16+StrToInt(Copy(strSub,2,1));
          strR:=strR+Chr(i);      //get two char of the next source data
          strSub:=copy(strSrc,1,2);
          strSrc:=Copy(strSrc,3,Length(strSrc)-2);
       end;   //result
       Result := strR;
    end;
      

  9.   

    IntToHex 将整数转换成十六进制