我的发票是套打
发票上已有‘  拾  万  仟  佰  拾  元  角  分 ’求小写转大写程序如1500元
转成   零 拾 零 万 壹 仟 伍 佰 零 拾 零 元 零 角 零 分
  

解决方案 »

  1.   

    参考一下这个
    function TFun.ToBigRMB(RMB: string): string; 
    const 
      BigNumber = '零壹贰叁肆伍陆柒捌玖'; 
      BigUnit   = '万仟佰拾亿仟佰拾万仟佰拾元'; 
    var 
      nLeft,nRigth,lTemp,rTemp,BigNumber1,BigUnit1:string; 
      I:Integer; 
      minus:boolean; 
    begin 
     try 
      minus:=false; 
      {取整数和小数部分} 
      if StrToFloat(rmb)<0 then 
        begin 
          RMB:=FloatToStrF(ABS(StrToFloat(RMB)),fffixed,20,2); 
          minus:=true; 
        end 
      else 
          RMB:=FloatToStrF(ABS(StrToFloat(RMB)),fffixed,20,2); 
     
      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 trim(ltemp)='元' then ltemp:='零'+ltemp; 
     
       if Pos('亿万', lTemp)<>0 then Delete(lTemp, Pos('亿万', lTemp) + 2, 2);  {转换小数部分} 
     
       if (trim(copy(ltemp,length(ltemp)-3,2))<>'')and(pos(copy(ltemp,length(ltemp)-3,2),bigunit)>0)and(StrToInt(nRigth[1])<>0 or StrToInt(nRigth[2])) then ltemp:=ltemp+'零'; 
     
       if (trim(ltemp)='零元')and(StrToInt(nRigth[1])<>0 or StrToInt(nRigth[2])) then ltemp:=''; 
     
       if minus then ltemp:='(负)'+ltemp; 
     
       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)and((rightstr(ltemp,2)<>'零')and(trim(rightstr(ltemp,2))<>'')) then rTemp:='零'; 
           rTemp:=rTemp + copy(BigNumber, StrToInt(nRigth[2]) * 2 + 1, 2) + '分'; 
           Result:='(人民币):'+lTemp + rTemp; 
         end 
       else 
         Result:='(人民币):'+lTemp + rTemp + '整'; 
      except 
         Result:='非法数据'; 
      end; 
    end; 
      

  2.   

    把二楼的改一下不就可以了
    BigUnit  = '                        元'; 
      

  3.   

    改改就可以了
    function TForm1.NumToChar(const n: Real): string;   //可以到万亿,并且可以随便扩大范围
    const
      cNum: WideString = '零壹贰叁肆伍陆柒捌玖万仟佰拾亿仟佰拾万仟佰拾';
    var
      i : Integer;
      sNum,sTemp,sDecimal: WideString;
      str: String;
    begin
      str :='';
      sNum :=  format('%15d',[round(n)]);
      sDecimal := copy(formatfloat('#.############',n),
                       pos('.',formatfloat('#.############',n))+1,
                       length(formatfloat('#.############',n))-pos('.',formatfloat('#.############',n)));
      sDecimal :=  format('%15d',[round(StrToFloat(sDecimal))]);
      for i := 0 to 14 do
      begin
        stemp := copy(snum,i+1,1);
        if stemp=' ' then continue
        else str := str + cNum[strtoint(stemp)+1] + cNum[i+9];
      end;
      str:=trim(str);
      if StrtoFloat(sDecimal)>0 then
      begin
        str := str +'点';
        for i:=0 to 14 do
        begin
          stemp := copy(sDecimal,i+1,1);
          if stemp=' ' then continue
          else str := trim(str) + cNum[strtoint(stemp)+1];
        end;
      end;
      Result := str;
    end;
      

  4.   

    那不是更容易了,呵呵function ConvertMoney(m:double):string;
    const
      cNum: WideString = '零壹贰叁肆伍陆柒捌玖';
    var
      s:string;
      i:integer;
    begin
      result:='';
      s:=format('%.8d',[round(M*100)]);
      for i:=1 to 8 do
        result:=result+cNum[strtoint(s[i])+1];
    end;把返回的字符串按照位置一个字符一个字符放上去
      

  5.   

    procedure TForm1.Button1Click(Sender: TObject);
    const
      rmbNumber: array[0..10] of string=('零','壹','贰','叁','肆','伍','陆','柒','捌','玖','点'); {定义数组}
      rmbUnit:array[0..15] of string=('厘','分','角','元','拾','佰','仟','万','拾','佰','仟','亿','拾','佰','仟','万');
    var i,j:integer;                  {定义枚举变量}
        s,t:string;
    begin   s:=edit1.Text ;
       j:=pos('.',s);
       if j=0 then
          j:=3
       else
          j:=3-(length(s)-j);
       for i:= length(s) downto 1 do
       begin
           case s[i] of
             '.':begin t:=rmbNumber[10]+t; end;
             else begin t:=rmbNumber[strtoint(s[i])]+rmbUnit[j]+t;inc(j);end;
           end;
      end;
      t:=rmbNumber[0]+rmbUnit[j]+t;
      edit2.Text :=t;
    end;
      

  6.   

    根据楼上修改的~~
    function ToBigRMB(RMB: string): string; 
    const 
      rmbNumber: array[0..10] of string=('零','壹','贰','叁','肆','伍','陆','柒','捌','玖','点'); {定义数组}
    var i,j:integer;                  {定义枚举变量}
        n,m:integer;//零的个数,整数位数,
        s,t:string; 
    begin 
      s:=edit1.Text;
      m:=length(inttostr(trunc(strtofloat(s))));
      j:=pos('.',s);
      if j=0 then
          j:=2
      else
          j:=2-(length(s)-j);
      for i:= length(s) downto 1 do 
      begin 
          case s[i] of
            '.':begin t:='  '+t;end;
            else begin t:=rmbNumber[strtoint(s[i])]+'      '+t;inc(j);end;
          end;
      end;
      n:=6-m;//6为十万(100000)的整数个数
      if  (pos('.',s)-6)=1 then
      begin
      result:=t ;
      end
      else
      begin
       repeat
        t:=rmbNumber[0]+'      '+t;
        dec(n);
       until n = 0;
       result:=t;
      end;
    end;
      

  7.   

    这个功能,Excel都能实现,何必这么麻烦
      

  8.   

    function ConvertMoney(m:double):string; 
    const 
      cNum: WideString = '零壹贰叁肆伍陆柒捌玖'; 
    var 
      s:string; 
      i:integer; 
    begin 
      result:=''; 
      s:=format('%.8d',[round(M*100)]); 
      for i:=1 to 8 do 
        result:=result+cNum[strtoint(s[i])+1]+'  '; 
    end; 
    这样行吧