⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 用delphi编写人民币转换小写程序.txt

📁 小写金额转大写金额
💻 TXT
字号:
{用Delphi编写人民币大小写转换程序
在财务管理系统中,有时需要打印大写人民币数字,于是笔者编写了以下一些函数使这一需要得以满足,现介绍如下:
注:copy(2005-Jey-QQ:344430663)本程序在Delphi7、Winwin2000下调试通过。}
function TForm1.shuzi(jey: string):string ;
var
 i:integer;
 s,s1,s2:integer;
 ab:integer;
 a,b,s3,s4:string;
begin
 i:=1; ab:=0; a:=''; b:='';s:=0;s1:=0;s2:=0;s3:='0';s4:='0';
 while i<=length(jey) do
 begin
  ab:=strtoint(shuzi1(copy(jey,i,2)));
  if ab=10000000 then
  begin
   b:=copy(jey,i+2,length(jey));
   a:=copy(jey,1,i-1)+'元';
  end;
  i:=i+2;
 end;  //end-- while
 if length(b)=0 then b:=jey;
 i:=1;
 while i<=length(b)  do
 begin
  s1:=strtoint(shuzi1(copy(b,i,2)));
  if s1 in [0..9] then
  begin
   s:=s1;
  end
  else
  begin
   s:=s1*s;
   s3:=inttostr((s)+strtoint(s3));
   s:=0;
  end;
  i:=i+2;
 end;  //end-- while  

 i:=1;s:=0;s1:=0;s2:=0;
 while i<=length(a)  do
 begin
  s1:=strtoint(shuzi1(copy(a,i,2)));
  if s1 in [0..9] then
  begin
   s:=s1;
  end
  else
  begin
   s:=s1*s;
   s4:=inttostr((s)+strtoint(s4));
   s:=0;
  end;
  i:=i+2;
 end;  //end-- while 

 if length(s4)>1 then
 result:=inttostr(strtoint(copy(s4,1,length(s4)-3))*10000+(strtoint(s3)div 1000))
 else
 result:=inttostr(strtoint(s3)div 1000);
 if strtoint(copy(s3,length(s3)-1,1))<>0 then
  result:=result+'.'+copy(s3,length(s3)-2,2)
 else if strtoint(copy(s3,length(s3)-2,1))<>0 then
  result:=result+'.'+copy(s3,length(s3)-2,1);

end;   //end-- begin

function TForm1.shuzi1(jey: string):string;
var
i:integer;
s:integer;
s1:string;
shu1:array of string[2];
begin
s1:='168';
i:=0;
 SetLength(shu1,17);
    shu1[16]:='万';shu1[15]:='仟';
    shu1[14]:='佰'; shu1[13]:='拾'; shu1[12]:='元';shu1[11]:='角';shu1[10]:='分';
    SHU1[0]:='零';SHU1[1]:='壹';SHU1[2]:='贰';SHU1[3]:='叁';SHU1[4]:='肆';
    SHU1[5]:='伍';SHU1[6]:='陆';SHU1[7]:='柒';SHU1[8]:='捌';SHU1[9]:='玖';
 for i:=0 to 16 do
 begin
   if jey<>shu1[i] then continue;
   s:=i;
   break;
 end;
case s of
0:s1:='0';
1:s1:='1';
2:s1:='2';
3:s1:='3';
4:s1:='4';
5:s1:='5';
6:s1:='6';
7:s1:='7';
8:s1:='8';
9:s1:='9';
10:s1:='10';
11:s1:='100';
12:s1:='1000';
13:s1:='10000';
14:s1:='100000';
15:s1:='1000000';
16:s1:='10000000';
end;
result:=s1;
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -