- 论坛徽章:
- 0
|
急求函数!关于金额转换!
小写金额转换成大写金额
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
lendec=2
end if
string dxint[13],dxdec[2],sz[13]
string dxstr="万仟佰拾亿仟佰拾万仟佰拾元"
string szstr="零壹贰叁肆伍陆柒捌玖"
for i=1 to 13
dxint=mid(dxstr,26 - i*2+1,2)
if i<11 then
sz=mid(szstr,i*2 - 1,2)
else
sz=" "
end if
next
dxdec[1]="角"
dxdec[2]="分"
dxstr=" "
for i = 1 to lenint
a = mid(mid(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="亿" 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="分" then
b=""
else
b=sz[integer(a) + 1]
end if
if a<>"0" then
dxstr=dxstr+b+dxdec
else
dxstr=dxstr+b
end if
next
if lendec=0 then dxstr=dxstr+"整"
return dxstr
稍加修改便可 |
|