比如字符串“ABCD1234”var BytMaskBit: array[1..200] of byte;
要得到:
BytMaskBit[1]=$ab
BytMaskBit[2]=$cd
BytMaskBit[3]=$12
BytMaskBit[4]=$34
初学DELPHI,基本功不好,谢谢指导!

解决方案 »

  1.   

    http://hi.csdn.net/link.php?url=http://blog.csdn.net%2Fliangpei2008
      

  2.   

    //连具体博客文章都引用不了,CSDN太差劲了# var  
    #   buf: array[0..100] of byte;  
    #   str: string[32];//仅仅开辟了一个32个空间的内存,由于第1位没有用setlength初始化,导致长度不定  
    #   i  : Integer;  
    # begin  
    #  //如果在此处就对str进行赋值,str[0]位就有计数了,如果在使用之前没有对其进行使用,用SetLength进行赋值  
    #   for i := 50 to 81 do buf[i] := ord('A') + i -50;//测试数据  
    #   SetLength(str, 32);//设置str[0]=32;  
    #   Move(buf[50], str[1], 32);//内存复制  
    #   ShowMessage (str);  
    # end;  
      

  3.   

    var 
      i:integer;
    const 
      ValueAA = (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); 
      ConValueAry :array[ValueAA] = (0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f);  i := 1;
    str := UpperCase(str);
    where i < length(str) do   //str “ABCD1234”
    begin
      BytMaskBit[i] := ConValueAry[str[i div 2]] shl 4 + ConValueAry[str[i div 2 + 1]]
      inc(i,2); 
    end;没有测试,凭空写的,可能有点问题,自己改改就OK