Function ChinaYuan(Amt: Extended): String;
var
  C_U : Array[0..10] of String;
  C_D : Array[0..10] Of String;
        B_point_c: string;
        A_point_c:  string;
        Chinese_st: String;
        temp1:      String;
        temp2:      String;
        B_point   : Real;
        A_point   : Real;
        i:integer;
        c, : char;
label
 bbbb;
begin
   C_U[0]:='元';
   C_U[1]:='拾';
   C_U[2]:='佰';
   C_U[3]:='仟';
   C_U[4]:='万';
   C_U[5]:='拾';
   C_U[6]:='佰';
   C_U[7]:='仟';
   C_U[8]:='万';
   C_D[0]:='零';
   C_D[1]:='壹';
   C_D[2]:='贰';
   C_D[3]:='叁';
   C_D[4]:='肆';
   C_D[5]:='伍';
   C_D[6]:='陆';
   C_D[7]:='柒';
   C_D[8]:='捌';
   C_D[9]:='玖';
   :='0';
   Try
     If amt>=0 Then amt:=amt+0.005
     Else Begin amt:=amt - 0.005;
                :='1';
                amt:=-amt;
          End;
   except
      amt:=0;
   end;
   B_point := int(amt);
   A_point := frac(amt);
   B_point_c:= Floattostr(B_point);
   A_point_c:= copy(FloatToStrF(int(A_point*100)/100, ffFixed, 4, 2), 3, 2);   i:=1;
   If B_point <> 0 Then
   Begin
      While i<=length(B_point_c) Do
      begin
         if (copy(B_point_c,i,1)='0') and (copy(B_point_c,i+1,1) = '0') then
            begin
               temp1:=copy(B_point_c,1,i-1);
               temp2:=copy(b_point_c,i+1,length(B_point_c));
               B_point_c:=concat(temp1,'!');
               B_point_c:=concat(B_point_c,temp2);
            end;
         i:=i+1;
      end;
      i:=0;
      while i<length(B_point_c) do
      begin
         temp1:= Copy(B_point_c,Length(b_point_c)-i,1);
         c := temp1[1];
         Case c of
            '0':Begin If (i=0) then Chinese_st := concat('元',Chinese_st)
                      Else Chinese_st := concat(C_D[strtoint(temp1)],Chinese_st);
                      If (i=4) or (i=8) then Chinese_st := concat('万',Chinese_st);
                End;
            '!':If (i=4) or (i=8) then Chinese_st := concat('万',Chinese_st);
            else
               Begin
                  Chinese_st := concat(C_U[i],Chinese_st);
                  Chinese_st := concat(C_D[strtoint(temp1)],Chinese_st);
               end;
         end;
         i := i+1;
      end;
   End;
   If A_point_c <> '00' then
      Begin
        temp1:= copy(A_point_c,1,1);
        temp2:= copy(A_point_c,2,1);
        If temp1 = '0' then
           begin
             If Chinese_st = '' then
                begin
                   Chinese_st := concat(Chinese_st,C_D[strtoint(temp2)]);
                   Chinese_st := concat(Chinese_st,'分');
                end
             Else
                begin
                   Chinese_st := concat(Chinese_st,C_D[strtoint(temp1)]);
                   Chinese_st := concat(Chinese_st,C_D[strtoint(temp2)]);
                   Chinese_st := concat(Chinese_st,'分');
                End;
             goto bbbb;
           end;
        if  temp2 = '0' then
           begin
             Chinese_st := concat(Chinese_st,C_D[strtoint(temp1)]);
             Chinese_st := concat(Chinese_st,'角');
             goto bbbb;
           end;
        Chinese_st := concat(Chinese_st,C_D[strtoint(temp1)]);
        Chinese_st := concat(Chinese_st,'角');
        Chinese_st := concat(Chinese_st,C_D[strtoint(temp2)]);
        Chinese_st := concat(Chinese_st,'分');
      end
   Else If Chinese_st <> '' Then Chinese_st := concat(Chinese_st,'整')
        Else Chinese_st := concat(Chinese_st,'无');bbbb:
  If  = '1' Then Chinese_st := concat('负',Chinese_st);
  Result:= chinese_st;
end;给你一个函数.

解决方案 »

  1.   

    下面修改并简单测试过,function TForm1.xTOd(i:Real):string;
    const
      d='零壹贰叁肆伍陆柒捌玖分角元拾佰仟万拾佰仟亿拾佰仟万';
      //可以至万亿
    var
      m,k:string;
      j:integer;
      I: Integer;
    begin
      k:='';
      m:=floattostr(int(i*100));
      j:=length(m);
      while  j >= 1 do
      begin
        I:= 0;
        while m[Length(m)-j+1]='0' do
        begin
          Inc(I);
          begin
            Case j of
            11 :begin
                  k:=k+'亿';
                  I:= 0;
                end;
            7 : begin
                  if (length(m)<11) or (I1<3) then k:=k+'万';
                  I1:= 0;
                end;
            3 : begin
                  k:=k+'元';
                  I1:= 0;
                end;
            else
              if (j>1) and (m[Length(m)-j+2]<>'0') then k:=k+'零';
            end;
          end;
          if j >= 1 then Dec(j);
        end;
        if j < 1 then break;
        k:=k+d[(strtoint(m[Length(m)-j+1])+1)*2-1]+
          d[(strtoint(m[Length(m)-j+1])+1)*2]+d[(10+j)*2-1]+d[(10+j)*2];
        Dec(j);
      end;
      xTOd:=k;
    end;
      

  2.   

    Sorry,改正:
            7 : begin
                  if (length(m)<11) or (I1<3) then k:=k+'万';
                  I1:= 0;  //应该是I:= 0;
                end;
            3 : begin
                  k:=k+'元';
                  I1:= 0;  //I:= 0;
                end;
      

  3.   

    再改:
            7 : begin
                  if StrToInt(Copy(m,length(m)-9,length(m)-7)) > 0 then k:=k+'万';
                  I1:= 0;  //应该是I:= 0;
                end;
      

  4.   

    数字转人民币大写:
    http://qianfeng.diy.163.com/Num2RMB.zip
    有个dll和使用说明,直接使用,无需重复劳动.