RMB

unit func;

interface

uses
 SysUtils, Classes,Dialogs,shellapi, ComCtrls,dbtables,BDE;

function RMB(NN:real):string;

implementation

function RMB(NN:real):string;
var
  HZ,NS,NW,NA,N1,N2:string;
  LA,X,Nk:integer;
begin
 if NN>9999999999999.99 then
 begin
  MessageDlg('金额溢出.',mtError,[mbOk], 0);
  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;

end.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值