例如把1234.55————>一千二百三十四元五角五分!!
要考虑小数点

解决方案 »

  1.   

    给你个函数! 不要忘了给分!!
    //返加人民币的中文数值
    function fucCapYuan(NN:double):string;
    var
      HZ,NS,NW,NA,N1,N2:string;
      LA,X,Nk:integer;
    begin
      if NN>9999999999999.99 then
      begin
        Msgbox('金额溢出。','出错',MB_OK + MB_ICONSTOP);
        HZ:='';
        Result:=HZ;
        exit;
      end;
      if NN=0 then
      begin
        HZ:='零元';
        result:=HZ;
        exit;
      end;
      NS:='零壹贰叁肆伍陆柒捌玖';
      NW:='分角元拾佰仟万拾佰仟亿拾佰仟万';
      NA:=FloatToStr(NN*100);
      LA:=length(NA);
      X:=1;
      HZ:='';
      while X<=LA do
      begin
      NK:=Ord(NA[x])-Ord('0');
      N1:=Copy(NS,NK*2+1,2);
      N2:=Copy(NW,LA*2+1-X*2,2);
      if (NK=0) AND ((N2='亿') OR( N2='万') OR( N2='元'))then
      begin
        if copy(HZ,Length(HZ)-1,2)='零' then
          HZ:=copy(HZ,1,length(HZ)-2);
        if copy(HZ,Length(HZ)-1,2)='亿' then
          if N2='元' then
          begin
            N1:=N2;
            N2:='零';
          end
          else
            N2:=''
        else
        begin
          N1:=N2;
          N2:='零';
        end
      end
      else if NK=0 then
        begin
          if copy(HZ,length(HZ)-1,2)='零' then
            N1:='';
            if N2='分' then
            begin
              if copy(HZ,length(HZ)-1,2)='零' then
                HZ:=copy(HZ,1,length(HZ)-2)+'整'
              else
                HZ:=HZ+'整';
                N1:='';
              end;
              N2:='';
            end;
          HZ:=HZ+N1+N2;
          X:=X+1
        end;
        Result:=HZ;
    end;
      

  2.   

    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 
      sum:=12.34; 
      showmessage('人民币大写:'+xTOd(Sum)); 
    end; 
      

  3.   

    给你一个程序,包管用,这容易。
    function Tform1.SmallTOBig(small:real):string;
    var SmallMonth,BigMonth:string;
    wei1,qianwei1:string[2];
    wei,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);”他自动默认小数点后两位 
      

  4.   

    财务软件中总少不了大写的金额表示方式,如下为一个简单的小写金额转换为大写的函数,其思路简单(可以说烂吧,居然利用了位置来转换),但是它却几乎可以无限制的转换,只要你能读得出来和写得进去:
    function Tform1.SmallTOBig(small:real):string;
    var SmallMonth,BigMonth:string;
    wei1,qianwei1:string[2];
    wei,qianwei,dianweizhi,qian:integer;
    begin
    {------- 修改参数令值更精确 -------}
    {小数点后的位数,需要的话也可以改动该值}
    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)) of1: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);”他自动默认小数点后两位