Function  TFormFhdCw.XxToDx(const hjnum:real):String;
var Vstr,zzz,cc,cc1,Presult:string;
    xxbb:array[1..12]of string;
    uppna:array[0..9] of string;
    iCount,iZero,vPoint,vdtlno:integer;
begin
  //*设置大写中文数字和相应单位数组*//
  xxbb[1]:='亿';
  xxbb[2]:='仟';
  xxbb[3]:='佰';
  xxbb[4]:='拾';
  xxbb[5]:='万';
  xxbb[6]:='仟';
  xxbb[7]:='佰';
  xxbb[8]:='拾';
  xxbb[9]:='元';
  xxbb[10]:='.';
  xxbb[11]:='角';
  xxbb[12]:='分';
  uppna[0]:='零';
  uppna[1]:='壹';
  uppna[2]:='贰';
  uppna[3]:='叁';
  uppna[4]:='肆';
  uppna[5]:='伍';
  uppna[6]:='陆';
  uppna[7]:='柒';
  uppna[8]:='捌';
  uppna[9]:='玖';
  Str(hjnum:12:2,Vstr);
  cc:='';
  cc1:='';
  zzz:='';
  result:='';
  presult:='';
  iZero:=0;
  vPoint:=0;
  for iCount:=1 to 10 do
    begin
      cc:=Vstr[iCount];
      if cc<>' ' then
        begin
          zzz:=xxbb[iCount];
          if cc='0' then
          begin
            if iZero<1 then  //*对“零”进行判断*//
               cc:='零'
            else
               cc:='';
            if iCount=5 then     //*对万位“零”的处理*//
               if copy(result,length(result)-1,2)='零' then
                  result:=copy(result,1,length(result)-2)+xxbb[iCount]
+'零'
               else
                  result:=result+xxbb[iCount];
            cc1:=cc;
            zzz:='';
            iZero:=iZero+1;
          end
          else
            begin
              if cc='.' then
                begin
                  cc:='';
                  if (cc1='') or (cc1='零')  then
                  begin
                     Presult:=copy(result,1,Length(result)-2);
                     result:=Presult;
                     iZero:=15;
                  end;
                  if iZero>=1 then
                     zzz:=xxbb[9]
                  else
                     zzz:='';
                  vPoint:=1;
                end
              else
                begin
                  iZero:=0;
                  cc:=uppna[StrToInt(cc)];
                end
            end;
          result:=result+(cc+zzz)
        end;
    end;
    If Vstr[11]='0' then   //*对小数点后两位进行处理*//
    begin
       if Vstr[12]<>'0' then
       begin
          cc:='零';
          result:=result+cc;
          cc:=uppna[StrToInt(Vstr[12])];
          result:=result+(uppna[0]+cc+xxbb[12]);
       end
    end
    else
    begin
       if iZero=15 then
       begin
          cc:='零';
          result:=result+cc;
       end;
       cc:=uppna[StrToInt(Vstr[11])];
       result:=result+(cc+xxbb[11]);
       if Vstr[12]<>'0' then
       begin
          cc:=uppna[StrToInt(Vstr[12])];
          result:=result+(cc+xxbb[12]);
       end;
    end;
  result:=result+'正';
end;

解决方案 »

  1.   

    Function  TFormFhdCw.XxToDx(const hjnum:real):String;
    var Vstr,zzz,cc,cc1,Presult:string;
        xxbb:array[1..12]of string;
        uppna:array[0..9] of string;
        iCount,iZero,vPoint,vdtlno:integer;
    begin
      //*设置大写中文数字和相应单位数组*//
      xxbb[1]:='亿';
      xxbb[2]:='仟';
      xxbb[3]:='佰';
      xxbb[4]:='拾';
      xxbb[5]:='万';
      xxbb[6]:='仟';
      xxbb[7]:='佰';
      xxbb[8]:='拾';
      xxbb[9]:='元';
      xxbb[10]:='.';
      xxbb[11]:='角';
      xxbb[12]:='分';
      uppna[0]:='零';
      uppna[1]:='壹';
      uppna[2]:='贰';
      uppna[3]:='叁';
      uppna[4]:='肆';
      uppna[5]:='伍';
      uppna[6]:='陆';
      uppna[7]:='柒';
      uppna[8]:='捌';
      uppna[9]:='玖';
      Str(hjnum:12:2,Vstr);
      cc:='';
      cc1:='';
      zzz:='';
      result:='';
      presult:='';
      iZero:=0;
      vPoint:=0;
      for iCount:=1 to 10 do
        begin
          cc:=Vstr[iCount];
          if cc<>' ' then
            begin
              zzz:=xxbb[iCount];
              if cc='0' then
              begin
                if iZero<1 then  //*对“零”进行判断*//
                   cc:='零'
                else
                   cc:='';
                if iCount=5 then     //*对万位“零”的处理*//
                   if copy(result,length(result)-1,2)='零' then
                      result:=copy(result,1,length(result)-2)+xxbb[iCount]
    +'零'
                   else
                      result:=result+xxbb[iCount];
                cc1:=cc;
                zzz:='';
                iZero:=iZero+1;
              end
              else
                begin
                  if cc='.' then
                    begin
                      cc:='';
                      if (cc1='') or (cc1='零')  then
                      begin
                         Presult:=copy(result,1,Length(result)-2);
                         result:=Presult;
                         iZero:=15;
                      end;
                      if iZero>=1 then
                         zzz:=xxbb[9]
                      else
                         zzz:='';
                      vPoint:=1;
                    end
                  else
                    begin
                      iZero:=0;
                      cc:=uppna[StrToInt(cc)];
                    end
                end;
              result:=result+(cc+zzz)
            end;
        end;
        If Vstr[11]='0' then   //*对小数点后两位进行处理*//
        begin
           if Vstr[12]<>'0' then
           begin
              cc:='零';
              result:=result+cc;
              cc:=uppna[StrToInt(Vstr[12])];
              result:=result+(uppna[0]+cc+xxbb[12]);
           end
        end
        else
        begin
           if iZero=15 then
           begin
              cc:='零';
              result:=result+cc;
           end;
           cc:=uppna[StrToInt(Vstr[11])];
           result:=result+(cc+xxbb[11]);
           if Vstr[12]<>'0' then
           begin
              cc:=uppna[StrToInt(Vstr[12])];
              result:=result+(cc+xxbb[12]);
           end;
        end;
      result:=result+'正';
    end;
      

  2.   

    function ToBigRMB(RMB:string):string;
    const
      BigNumber='零壹贰叁肆伍陆柒捌玖';
      BigUnit='万仟佰拾亿仟佰拾万仟佰拾元';
      {共可表示13位金额}
    var
      nLeft,nRigth,lTemp,rTemp,BigNumber1,BigUnit1:string;
      I:Integer;
    begin
      {取整数和小数部分}
      RMB:=FormatCurr('0.00',StrToFloat(RMB));
      nLeft:=copy(RMB,1,Pos('.',RMB)-1);
      nRigth:=copy(RMB,Pos('.',RMB)+1,2);
      {转换整数部分}
      for I:=1 to Length(nLeft) do
       begin
         BigNumber1:=copy(BigNumber,StrToInt(nLeft[I])*2+1,2);
         BigUnit1:=copy(BigUnit,(Trunc(Length(BigUnit)/2)-Length(nleft)+I-1)*2+1,2);
         if (BigNumber1='零') and ((copy(lTemp,Length(lTemp)-1,2))='零')
           then lTemp:=copy(lTemp,1,Length(lTemp)-2);
         if (BigNumber1='零') and ((BigUnit1='亿') or (BigUnit1='万') or (BigUnit1='元')) then
           begin
             BigNumber1:=BigUnit1;
             if BigUnit1<>'元'
               then BigUnit1:='零'
               else BigUnit1:='';
           end;
         if (BigNumber1='零') and (BigUnit1<>'亿') and (BigUnit1<>'万') and (BigUnit1<>'元')
           then BigUnit1:='';
         lTemp:=lTemp+BigNumber1+BigUnit1;
      end;
      if Pos('亿万',lTemp)<>0
        then Delete(lTemp, Pos('亿万',lTemp)+2,2);
      {转换小数部分}
      if StrToInt(nRigth[1])<>0
        then rTemp:=copy(BigNumber,StrToInt(nRigth[1])*2+1,2)+'角';
      if StrToInt(nRigth[2])<>0 then
        begin
          if StrToInt(nRigth[1])=0 then rTemp:='零';
          rTemp:=rTemp+copy(BigNumber,StrToInt(nRigth[2])*2+1,2)+'分';
        end;
      Result:=lTemp+rTemp+'整';
    end;
      

  3.   

    function TForm1.xTOd(i:Real):string; 
    const 
      d='零壹贰叁肆伍陆柒捌玖分角元拾佰仟万拾佰仟亿'; 
    var 
      m,k:string; 
      j:integer; 
    begin 
      k:=''; 
      m:=floattostr(int(i*100)); 
      for j:=length(m) downto 1 do 
        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]; 
      xTOd:=k; 
    end; 调用: 
    procedure TForm1.Button1Click(Sender: TObject); 
    var 
      Sum:real; 
    begin