精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● Delphi>>Object Pascal语言>>Re: 谁有金额小写转大写的子程序

主题:Re: 谁有金额小写转大写的子程序
发信人: mr.ahua()
整理人: kingron(2000-12-05 19:30:04), 站内信件
【 在 chenmx (小喇叭) 的大作中提到: 】
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;


--
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 210.74.137.214]

[关闭][返回]