我手头有个Foxpro的挺不错,等有空时转成Delphi给你吧

解决方案 »

  1.   

    我有一个代码,但是有些问题(对0的操作)如果你要的话给我你的email吧,不过要给我分得哟  :)
      

  2.   

    我给你一段吧:
    FUNCTION ChinaTotal(Aje:Currency):string;
    var
      s_1,s_2:widestring;
      s_5:char;
      s_4:string;
      i:integer;
      mm:string;
      s_6,s_7:widestring;
    begin
      s_4:=format('%10d',[trunc(aje*100)]);
      s_1:='零壹贰叁肆伍陆柒捌玖';
      s_2:='仟佰拾万仟佰拾元角分';
      i:=1;
      mm:='';
      WHILE i<=10 do
      begin
        s_5:=s_4[i];
        IF s_5<>' ' then
        begin
            s_6:=s_1[ord(s_5)-ORD('0')+1];
            s_7:=s_2[i];
            IF (s_5='0') AND (i<>4) AND (i<>8)  then
              s_7:='';
            IF (copy(s_4,i,2)='00') OR ( (s_5='0') AND (i in [4,8,10])) then
              s_6:='';
            mm:=mm+s_6+s_7;
            IF (s_4[i]='0') AND ((s_4[i+1]<>'0') AND (i in [4,8])) then
              mm:=mm+s_1[1];
        END;
        inc(i);
      END ;
      IF s_5='0' then  mm:=mm+'整';
      result:=mm;
    end;
      

  3.   

    type
      TEnumMoneyUnitCn  = (eMUCYuan, eMUCJiao, eMUCFen); //中文货币单位枚举类型const
      cMaxCnNumMask = 12;                                //中文货币最大数位  cCnMoney = '¥';                                    //中文货币小写符号  cCnNumCodeLw: array['0' .. '9'] of string =    //中文数字列表1
      ('○', '一', '二', '三', '四', '五', '六', '七', '八', '九');  cCnNumCodeUp: array['0' .. '9'] of string =    //中文数字列表2
      ('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖');  cCnNumMaskLw: array[1 .. cMaxCnNumMask] of string = //中文数位列表1
      ('', '十', '百', '千', '万', '十', '百', '千', '乙', '十', '百', '千');  cCnNumMaskUp: array[1 .. cMaxCnNumMask] of string = //中文数位列表2
      ('', '拾', '佰', '仟', '万', '拾', '佰', '仟', '亿', '拾', '佰', '仟');  cCnMoneyCode: array[TEnumMoneyUnitCn] of string =  //中文货币单位列表
      ('圆', '角', '分');function StrLeft(const mStr: string; mDelimiter: string): string;
    begin
      Result := Copy(mStr, 1, Pos(mDelimiter, mStr) - 1);
    end; { StrLeft }function StrRight(const mStr: string; mDelimiter: string): string;
    begin
      if Pos(mDelimiter, mStr) <= 0 then
        Result := ''
      else Result := Copy(mStr, Pos(mDelimiter, mStr) + Length(mDelimiter), MaxInt);
    end; { StrRight }function Iif(mBool: Boolean; mDataA: Variant; mDataB: Variant): Variant;
    begin
      if mBool then
        Result := mDataA
      else Result := mDataB;
    end; { Iif }function ZsAToC(mFloat: Real): string; { 返回中文表示的数字 }
    var
      sTemp, lStr, rStr: string;
      J: Integer;{ ---------------------begin------------------------ }
      function fZsLeft(s: string): string;
      var
        I, K, Len: Integer;
        Hxm: Boolean; //出现0
        Lcy: Boolean;
      begin
        Result := '';
        Len := Length(s);
        J := 0;
        if s <> '0' then begin
          Hxm := False; Lcy := False;
          for I := 1 to Len do begin
            K := Len - I + 1;
            if s[I] <> '0' then begin
              J := 0;
              if Hxm then Result := Result + cCnNumCodeUp['0'];
              Result := Result +  Concat(cCnNumCodeUp[s[I]], cCnNumMaskUp[K]);
              Hxm := False;
              Lcy := True;
            end else begin
              Hxm := True;
              if (Lcy) and ((K + 4) mod 4 = 1) then begin
                J := K;
                if (Lcy) and (J <> 0) then Result := Result + cCnNumMaskUp[J];
                Lcy := False;
              end;
            end; { if[s[I] <> '0'] }
          end; { for }
        end { if[s <> '0'] }
        else Result := cCnNumCodeUp['0'];
      end; { fZsLeft }  function fZsRight(s: string): string;
      begin
        Result := '';
        if s <> '00' then begin
          Result := Result + Iif((Int(mFloat) = 0) and (s[1] = '0'), '',
            cCnNumCodeUp[s[1]]) + Iif(s[1] <> '0',
            cCnMoneyCode[eMUCJiao], '');
          if s[2] <> '0' then
            Result := Result + cCnNumCodeUp[s[2]] + cCnMoneyCode[eMUCFen];
        end else Result := '整';
      end; { fZsLeft }
    { ---------------------end------------------------ }begin
      if mFloat <> 0 then begin
        Str(mFloat:0:2, sTemp);
        lStr := fZsLeft(StrLeft(sTemp, '.'));
        rStr := fZsRight(StrRight(sTemp, '.'));
        Result := Iif(lStr = cCnNumCodeUp['0'], '', lStr + cCnMoneyCode[eMUCYuan])
                + rStr;
      end else Result := cCnNumCodeUp['0'] + cCnMoneyCode[eMUCYuan] + '整';
    end; { ZsAToC }
      

  4.   

    小写金额转换  如下为一个简单的小写金额转换为大写的函数,其思路简单(可以说烂吧,居然利用了位置来转换),但是它几乎可以无限制的转换,只要你能读得出来和写得进去:function Tform1.SmallTOBig(small:real):string;
    var SmallMonth,BigMonth:string;
        wei1,qianwei1:string[2];
        qianwei,dianweizhi,qian:integer;
    begin
       {------- 修改参数令值更精确 -------}
       {小数点后的位置,需要的话也可以改动-2值}
       qianwei:=-2;
       {转换成货币形式,需要的话小数点后加多几个零}
       Smallmonth:=formatfloat('0.00',small);
       {---------------------------------}
       dianweizhi :=pos('.',Smallmonth);{小数点的位置}
       {循环小写货币的每一位,从小写的右边位置到左边}
       for qian:=length(Smallmonth) downto 1 do
       begin
         {如果读到的不是小数点就继续}
         if qian<>dianweizhi then
         begin
         {位置上的数转换成大写}
            case strtoint(copy(Smallmonth,qian,1)) of
              1:wei1:='壹'; 2:wei1:='贰';
              3:wei1:='叁'; 4:wei1:='肆';
              5:wei1:='伍'; 6:wei1:='陆';
              7:wei1:='柒'; 8:wei1:='捌';
              9:wei1:='玖'; 0:wei1:='零';
            end;
            {判断大写位置,可以继续增大到real类型的最大值}
            case qianwei of
              -3:qianwei1:='厘';
              -2:qianwei1:='分';
              -1:qianwei1:='角';
              0 :qianwei1:='元';
              1 :qianwei1:='拾';
              2 :qianwei1:='佰';
              3 :qianwei1:='千';
              4 :qianwei1:='万';
              5 :qianwei1:='拾';
              6 :qianwei1:='佰';
              7 :qianwei1:='千';
              8 :qianwei1:='亿';
              9 :qianwei1:='十';
              10:qianwei1:='佰';
              11:qianwei1:='千';
            end;
            inc(qianwei);
            BigMonth :=wei1+qianwei1+BigMonth;{组合成大写金额}
          end;
       end;
       SmallTOBig:=BigMonth;
    end;调用如下“edit1.text:=SmallTOBig(1234567890.1234);”他自动默认小数点后两位