关于金额小写转为大写的问题。

li_sj 2002-11-28 01:18:17
本人正在编写一个数据库软件,需要将小写的阿拉伯数字转成发票中的大写形式,请各位大虾帮帮忙,万分感谢。
...全文
62 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
匿名用户12345 2002-11-28
  • 打赏
  • 举报
回复
呵呵,这么多人回答你啊


我以前做的一个东西,里面有你的这个功能,如你需要给我发消息
hmily1688 2002-11-28
  • 打赏
  • 举报
回复
楼主,请你提问前serch 一把,这问题问了n次了.老这样不好玩
chwdong 2002-11-28
  • 打赏
  • 举报
回复
initialization
chn_number[0]:='零';
chn_number[1]:='壹';
chn_number[2]:='贰';
chn_number[3]:='叁';
chn_number[4]:='肆';
chn_number[5]:='伍';
chn_number[6]:='陆';
chn_number[7]:='柒';
chn_number[8]:='捌';
chn_number[9]:='玖';

chn_sectionunit[0]:='';
chn_sectionunit[1]:='万';
chn_sectionunit[2]:='亿';
//over

end.


function chn_money(money: double): string;
var
intpart, chiao, cent: integer;
fracpart: double;
signstr, tstr: string;
begin
signstr:='';
if (money<0) then
begin
money:=-money;
signstr:='负';
end;
money:=money+0.005; //包含四舍五入
intpart:=Trunc(money); //Trunc truncates a real number to an integer.
fracpart:=money-intpart;
fracpart:=fracpart*10;
chiao:=Trunc(fracpart);
fracpart:=fracpart-chiao;
fracpart:=fracpart*10;
cent:=Trunc(fracpart);
tstr:=chn_intvalue(intpart);
if (chiao=0) and (cent=0) then
result:=tstr+'元整';
if (chiao <> 0) and (cent = 0) then
result:=tstr+'元'+chn_number[chiao]+'角整';
if (chiao=0) and (cent <> 0) then
result:=tstr+'元'+'零'+chn_number[cent]+'分';
if (chiao <> 0) and (cent <> 0) then
result:=tstr+'元'+chn_number[chiao]+'角'+chn_number[cent]+'分';
result:=signstr+result;
end;
mengxianbao1521 2002-11-28
  • 打赏
  • 举报
回复
决定的正确
//----------------------- function SmallToBig----------------------------
// 小写转化为大写
//-----------------------------------------------------------------------
function SmallTOBig(small:real):string;
var
SmallMonth,BigMonth,wei,shu,BigMonth1:string;
wei1,qianwei1:string[2];
qianwei,dianweizhi,qian:integer;
havezero:Boolean;
begin
wei:='';
shu:='';
BigMonth1:='';
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;
{判断大写位置}
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;{组合成大写金额}
shu:=wei1+shu;
wei:=qianwei1+wei;
end;
end;
havezero:=False;
{去掉多余零}
//showmessage(shu+wei);
for qian:=1 to ((length(shu) div 2)-2) do
begin
if (copy(shu,2*qian-1,2)='零') and ((copy(wei,2*qian-1,2)='万') or (copy(wei,2*qian-1,2)='元') or (copy(wei,2*qian-1,2)='亿'))then
begin
havezero:=False;
BigMonth1:=BigMonth1+copy(wei,2*qian-1,2);
end
else if (copy(shu,2*qian-1,2)='零') and not ((copy(wei,2*qian-1,2)='万') or (copy(wei,2*qian-1,2)='元') or (copy(wei,2*qian-1,2)='亿'))then
havezero:=True
else
begin
if havezero then
begin
BigMonth1:=BigMonth1+'零'+copy(shu,2*qian-1,2)+copy(wei,2*qian-1,2);
havezero:=False;
end
else
BigMonth1:=BigMonth1+copy(shu,2*qian-1,2)+copy(wei,2*qian-1,2);
end;
end;
qian:=(length(shu) div 2)-2;
if (copy(shu,2*qian+1,2)='零') and (copy(shu,2*qian+3,2)='零') then
BigMonth1:=BigMonth1+'整';
if (copy(shu,2*qian+1,2)='零') and (copy(shu,2*qian+3,2)<>'零') then
BigMonth1:=BigMonth1+'零'+copy(shu,2*qian+3,2)+copy(wei,2*qian+3,2);
if (copy(shu,2*qian+1,2)<>'零') and (copy(shu,2*qian+3,2)='零') then
BigMonth1:=BigMonth1+copy(shu,2*qian+1,2)+copy(wei,2*qian+1,2)+'整';
if (copy(shu,2*qian+1,2)<>'零') and (copy(shu,2*qian+3,2)<>'零') then
BigMonth1:=BigMonth1+copy(shu,2*qian+1,2)+copy(wei,2*qian+1,2)+copy(shu,2*qian+3,2)+copy(wei,2*qian+3,2);
//SmallTOBig:=BigMonth;
SmallTOBig:=BigMonth1;
end;
blueshu 2002-11-28
  • 打赏
  • 举报
回复
function tmainform.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;
killlaoli 2002-11-28
  • 打赏
  • 举报
回复
这问题以前有人问过的,我就不粘贴了,太无耻了,呵呵。
去这看看,以后问问题前建议先搜索一下,可以节约可用分,呵呵。

http://expert.csdn.net/Expert/topic/1020/1020018.xml?temp=.9420435

5,931

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧