1、小写金额转换成大写金额
(深圳:独孤求败 2003-05-27)
在很多如打印发票的地方需要打印金额的中文大写,PowerBuilder没有提供这样一个数字转换成金额大写的函数。我就自己编了一个,在实际使用中效果良好。
程序源代码如下:
int i,lendec,lenint
string numstr,a,b,c,d,bbak
numstr=string(aje,"#0.00")
lenint=len(mid(numstr,1,pos(numstr,'.') - 1))
if right(numstr,2)='00' then
lendec=0
else
len
2、dec=2
end if
string dxint[13],dxdec[2],sz[13]
string dxstr="万仟佰拾亿仟佰拾万仟佰拾元"
string szstr="零壹贰叁肆伍陆柒捌玖"
for i=1 to 13
dxint[i]=mid(dxstr,26 - i*2+1,2)
if i<11 then
sz[i]=mid(szstr,i*2 - 1,2)
else
sz[i]=" "
end if
next
dxdec[1]="角"
dxdec[2]="分"
dxstr=" "
for i = 1 to lenint
a = mid(mid(
3、numstr,1,lenint),i,1)
b = sz[integer(a)+1]
c = dxint[lenint - i +1]
if dxstr<>" " then
d = mid(dxstr,len(dxstr) - 1 ,2)
else
d = " "
end if
if b="零" and (d="零" or b=bbak or c="元" or c="万" or c="亿") then b=
""
if a="0" and c<>"元" and c<>"万" and c<>"亿" then c=""
if (c="元" or c="万" or c="亿")
4、 and d="零" and a="0" then
dxstr=mid(dxstr,1,len(dxstr) - 2)
d = mid(dxstr,len(dxstr) - 1,2)
if (c="元" and d="万" or c="万"and d="亿") then c=""
end if
dxstr=dxstr + b + c
bbak = b
next
for i=1 to lendec
a = mid (mid(numstr,lenint+2,lendec),i,1)
if a="0" and dxdec[i]="分" then
b=""
else
b=sz[integer(a) + 1]
end if
if a<>"0" then
dxstr=dxstr+b+dxdec[i]
else
dxstr=dxstr+b
end if
next
if lendec=0 then dxstr=dxstr+"整"
return dxstr