或者(123.05转化成'壹百贰拾叁点零伍')

解决方案 »

  1.   

    小写金额转换为大写 
    //本函数用于将小于十万亿元的小写金额转换为大写
    Function NtoC( n0 :real) :String;
    Function IIF( b :boolean; s1,s2 :string) :string;
    begin if b then IIF:= s1 else IIF:=s2;
    end; //本函数的功能一目了然: 当b为真时返回s1,否则返回s2
    Const c= ’零壹贰叁肆伍陆柒捌玖◇分角圆拾佰仟万拾佰仟亿拾佰仟万’;
    var L,i,n :integer; Z :boolean; s,s1,s2 :string;
    begin
     s:= FormatFloat( ’0.00’, ABS(n0));
     L:= Length( s);
     Z:= n0<1;
     For i:= 1 To L-3 do
      begin
       n:= StrToInt( s[ L-i-2]);
       s1:=IIf((n=0)And(Z Or (i=9) Or (i=5) Or (i=1)), ’’, Copy( c, n*2+1, 2))
       + IIf((n=0)And((i<>9)And(i<>5)And(i<>1) Or Z And(i=1)),’’,Copy(c,(i+13)*2-1,2))
       + s1;
       Z:= (n=0);
      end;
     Z:= False;
     For i:= 1 To 2 do
      begin
       n:= StrToInt( s[ L-i+1]);
       s2:= IIf((n=0)And((i=1) Or (i=2)And(Z Or (n0<1))), ’’, Copy( c, n*2+1, 2))
       + IIf( (n>0), Copy( c,(i+11)*2-1, 2), IIf( (i=2) Or Z, ’’,’整’))
       + s2;
       Z:= (n=0);
      end;
     For i:= 1 To Length( s1) do If Copy(s1, i, 4) = ’亿万’ Then Delete(s1,i+2,2);
     NtoC:= IIf(n0=0, ’零’, IIF(n0<0, ’-’,’’)+ s1+s2);
    End;
    //对于大写金额中“零”的用法,习惯不同,清指正。
    //在FoxPro、VB中,IIF都是内部函数。但Delphi没有,只得自己定义。
      

  2.   

    我收藏的,试过了,绝对可用function BigRBM(sn: Double): string;
    var
      dx: array[1..14] of string;
      dd: array[0..9] of string;
      s, ss: string;
      L, i, n: integer;
      zero, plus: boolean;
    begin{单位}  dx[1] := '分';
      dx[2] := '角';
      dx[3] := '元';
      dx[4] := '拾';
      dx[5] := '佰';
      dx[6] := '仟';
      dx[7] := '万';
      dx[8] := '拾';
      dx[9] := '佰';
      dx[10] := '仟';
      dx[11] := '亿';
      dx[12] := '拾';
      dx[13] := '佰';
      dx[14] := '仟';{数值}  dd[0] := '零';
      dd[1] := '壹';
      dd[2] := '贰';
      dd[3] := '叁';
      dd[4] := '肆';
      dd[5] := '伍';
      dd[6] := '陆';
      dd[7] := '柒';
      dd[8] := '捌';
      dd[9] := '玖';  zero := False;
      sn := sn * 100; //把小数前两位转换成整数  if sn < 0 then //取得符号标志值plus
      begin
        plus := False; //负数
        sn := sn * (-1); //变成正数
      end
      else if sn > 0 then plus := True
      else //等于0
      begin
        Result := '零元整';
        exit;
      end;  ss := FloatToStr(int(sn)); //截取整数部份,再转换为字符串
      L := length(ss); //取得长度
      for i := 1 to L do
      begin
        n := StrToInt(copy(ss, L - i + 1, 1)); //取得单个数字
        if n = 0 then
        begin
          if (i = 3) or (i = 11) then s := dx[i] + s //元、亿前不写0
          else if (i = 7) then
          begin
            if (StrToInt(Copy(ss, L - 9, 4)) <> 0) then
            begin
              if zero then s := dx[i] + s //当千万至万不为0时,只写"万"
              else if (not zero) then s := dx[i] + dd[n] + s;
            end
            else
            begin
              if not zero then s := dd[n] + s;
            end;
          end
          else if (not zero) and (i > 1) then s := dd[n] + s; //当后耐不是0并为整数位时,写0
          Zero := True;
        end
        else
        begin
          s := dd[n] + dx[i] + s; //正常
          Zero := False;
        end;
      end;
      if plus then Result := s + '整'
      else Result := '负' + s + '整';
    end;
      

  3.   

    function xToD(const Num:Real):String;
    //小写金额转大写金额
    var
      aa,bb,cc:string;
      bbb:array[1..16]of string;
      uppna:array[0..9] of string;
      i:integer;
    begin
       bbb[1]:='万';
       bbb[2]:='仟';
       bbb[3]:='佰';
       bbb[4]:='拾';
       bbb[5]:='亿';;
       bbb[6]:='仟';;
       bbb[7]:='佰';
       bbb[8]:='拾';
       bbb[9]:='万';
       bbb[10]:='仟';
       bbb[11]:='佰';
       bbb[12]:='拾';
       bbb[13]:='元';
       bbb[14]:='.';
       bbb[15]:='角';
       bbb[16]:='分';
       uppna[1]:='壹';
       uppna[2]:='贰';
       uppna[3]:='叁';
       uppna[4]:='肆';
       uppna[5]:='伍';
       uppna[6]:='陆';
       uppna[7]:='柒';
       uppna[8]:='捌';
       uppna[9]:='玖';
       Str(num:16:2,aa);
       cc:='';
       bb:='';
       result:='';
       for i:=1 to 16 do
         begin
           cc:=aa[i];
           if cc<>' ' then
             begin
              bb:=bbb[i];
               if cc='0' then
                 cc:='零'
               else
                 begin
                   if cc='.' then
                     begin
                       cc:='';
                       bb:='';
                     end
                   else
                     begin
                       cc:=uppna[StrToInt(cc)];
                     end
                 end;
               result:=result+(cc+bb)
             end;
         end;
       //result:=result+'正';
    end;
      

  4.   

    function show(v_1:integer):string;
    begin
      case v_1 of
      1: result:='分';
      2: result:='角';
      3: result:='';
      4: result:='';
      5: result:='拾';
      6: result:='佰';
      7: result:='仟';
      8: result:='';
      9: result:='拾';
      10: result:='佰';
      11: result:='仟';
      12: result:='億';
      13: result:='拾';
      end;
    end;function smalltobig1(v_no:integer):string;
    begin
      case v_no of
      0: result:='零';
      1: result:='壹';
      2: result:='貳';
      3: result:='參';
      4: result:='肆';
      5: result:='伍';
      6: result:='陸';
      7: result:='柒';
      8: result:='捌';
      9: result:='玖';
      end;
    end;function big(v_str:string):string;
    var v_len,i,j,k,a:integer;
        v_str1,v_str2:string;
        v_flag,v_flag1:integer;
    begin
      a:=1;
      v_flag:=0;  //元的標志
      v_flag1:=0; //萬的標志
      v_str2:='';
      v_len:=length(v_str);
      if v_len>13 then exit;
      v_str1:=copy(v_str,v_len-2,1);
      if v_str1<>'.' then
        begin
          v_str1:=copy(v_str,v_len-1,1);
          if v_str1<>'.' then
            v_str:=v_str+'.00'
          else
            v_str:=v_str+'0';
        end;
      v_len:=length(v_str);
      if v_len>13 then exit;
      k:=1;
      for i:=1 to v_len do
      begin
        v_str1:=copy(v_str,v_len-i+1,1);
        if v_str1<>'.' then
        begin
          j:=strtoint(v_str1);
          if (j<>0) and (k>=3) then v_flag:=v_flag+1;
          if (j<>0) and (k>=8) and (k<=11) then v_flag1:=v_flag1+1;
          if j<>0 then     //數字不為0
            v_str1:=smalltobig1(j)+show(k)
          else if (a<>0) and (i<>1) and (i<>4) then v_str1:=smalltobig1(j)  //上一位為0且不為分位且不為'.'
          else v_str1:='';
          if (a=0) and (i=13) and (j<>0) then  v_str1:=v_str1+'億'; //億位為0﹐但十億位不為0
          if (k>=8) and (k<=11) and (v_flag1=1) and (j<>0) then  v_str1:=v_str1+'萬'; //沒有萬則加上萬
          if (k>=3) and  (v_flag=1) and (j<>0) then  v_str1:=v_str1+'圓'; //沒有圓則加上圓
          v_str2:=v_str1+v_str2;
          a:=j;
        end;
        k:=k+1;
      end;
      result:=v_str2;
    end;