怎么搞?

解决方案 »

  1.   

    function TMyClass.LowCaseToUppercase(sReal: real): string;
    Var
      i: Integer;
      j,dxhj: string;
      Zero: Boolean;
    begin
      j := Trim(inttostr(round(sReal*100)));
      if pos('.',j)<>0 then
        j := copy(j,1,pos('.',j)-1);
      if j = '' then
        j := '0';
      if copy(j,length(j),1)='0' then
      begin
        dxhj := '整';
        Zero := True;
      end
      else
      begin
        dxhj := '';
        Zero := False;
      end;
      for i:=0 to Length(j)-1 do
      begin
        if strtoint(copy(j,length(j)-i,1))<>0 then
        case i of
          0: dxhj := '分'+dxhj;
          1: dxhj := '角'+dxhj;
          3: dxhj := '拾'+dxhj;
          4: dxhj := '佰'+dxhj;
          5: dxhj := '仟'+dxhj;
          //6: dxhj := ''+dxhj;
          7: dxhj := '拾'+dxhj;
          8: dxhj := '佰'+dxhj;
          9: dxhj := '仟'+dxhj;
        end;
        if i=2 then
          dxhj := '元'+dxhj;
        if i=6 then
          dxhj := '万'+dxhj;
        case strtoint(copy(j,length(j)-i,1)) of
          0:begin
              if not Zero then
                dxhj := '零'+dxhj;
              Zero := True;
            end;
          1:begin
              dxhj := '壹'+dxhj;
              Zero := False;
            end;
          2:begin
              dxhj := '贰'+dxhj;
              Zero := False;
            end;
          3:begin
              dxhj := '叁'+dxhj;
              Zero := False;
            end;
          4:begin
              dxhj := '肆'+dxhj;
              Zero := False;
            end;
          5:begin
              dxhj := '伍'+dxhj;
              Zero := False;
            end;
          6:begin
              dxhj := '陆'+dxhj;
              Zero := False;
            end;
          7:begin
              dxhj := '柒'+dxhj;
              Zero := False;
            end;
          8:begin
              dxhj := '捌'+dxhj;
              Zero := False;
            end;
          9:begin
              dxhj := '玖'+dxhj;
              Zero := False;
            end;
          end;
      end;
      if dxhj='整' then
        dxhj := '';
      Result:= dxhj;
    end;
      

  2.   

    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;
      

  3.   

    财务软件中总少不了大写的金额表示方式,如下为一个简单的小写金额转换为大写的函数,其思路简单(可以说烂吧,居然利用了位置来转换),但是它却几乎可以无限制的转换,只要你能读得出来和写得进去: 
    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)) 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);”他自动默认小数点后两位