呵呵~~大哥,有这个函数吗?我试过没有啊,inttoBCD()也没有!

解决方案 »

  1.   

    还有这函数?bcb6 加的?13 本身是个数字,是不是asc码就看你怎么看。
      

  2.   

    delphi6.0有,以前版本我没看,要么你自己写个函数,逐位取出转换,然后再合成
      

  3.   

    Converts an integer value to the corresponding binary-coded decimal (BCD) value.UnitFmtBcdCategoryBCD supportfunction IntegerToBcd( const aValue: Integer): TBcd;DescriptionUse IntegerToBcd to convert an integer into a binary-coded decimal value.
      

  4.   

    这个函数不难写.
    但是你首先要知道 BCD码分为压缩BCD码和非压缩BCD码。
    你的是哪种?比如你的13
    压缩BCD码: 0x13
    非压缩BCD码:0x0103
      

  5.   

    to pazee(耙子) 
    那么IntegerToBCD()转换的是压缩还是非压缩的呢?(:
      

  6.   

    function IntegerToBcd( const aValue: Integer): TBcd;type 
      TBcd  = packed record
        Precision: Byte;         { 1..64 }
        SignSpecialPlaces: Byte; { Sign:1, Special:1, Places:6 }
        Fraction: packed array [0..31] of Byte; { BCD Nibbles, 00..99 per Byte, high Nibble 1st }
      end;使用这个函数要用
    FmtBcd单元
      

  7.   

    你要的整数形式的转换,还是字符串形式的?
    下面是整数形式的,转换一个字节,多字节就逐个调用:function MyIntToBCD(data: BYTE): BYTE;
    begin
    Result := ((data div 10) * 16) or (data mod 10);
    end;
    // 例如: 37 => 0x37, 99 => 0x99
      

  8.   

    to:alexxing(赤铸) 我要通过COM1口发,那边接收的要BCD码,我想将整型的数转换成字符串发过去,
    就用以上的方法行吗?
      

  9.   

    IntToHex()得到的就是你的整形值的十六进制字符
    code:string;
    i:integer;
    begin
      code:='0x'+IntToHex(i);
    end;
      

  10.   

    你可以這樣試一試:
    StrTOBCD(IntToStr(13))
      

  11.   

    我用IntegerToBcd()转换后,怎么样可以加到一个字符串上去啊。
    那个字符串是:10023880(都是数字来的)
    用bcdtostr() 会将BCD码转换回来啊!