人民幣小寫金額轉換為大寫函數

程序代码:

<%functionMoney(thenumber)
dimMoney,i,String1,String2,length,checkp'定义变量
dimone(),onestr()'定义数组

String1="零壹贰叁肆伍陆柒捌玖"
String2="万仟佰拾亿仟佰拾万仟佰拾元角分厘毫"

checkp=instr(thenumber,".")'判断是否含有小数位
ifcheckp<>0then
thenumber=replace(thenumber,".","")'去除小数位
endif

length=len(thenumber)'取得数据长度
redimone(length-1)'重新定义数组大小
redimonestr(length-1)'重新定义数组大小

fori=0tolength-1

one(i)=mid(thenumber,i+1,1)'循环取得每一位的数字
one(i)=mid(string1,one(i)+1,1)'循环取得数字对应的大写


ifcheckp=0then
'不含有小数的数据其数字对应的单位
onestr(i)=mid(string2,14-length+i,1)
else
'含有小数的数据其数字对应的单位
onestr(i)=mid(string2,15-length+i+len(thenumber)-checkp,1)
endif

one(i)=one(i)&onestr(i)'将数字与单位组合
next

Money=replace(join(one),"","")'取得数组中所有的元素,并连接起来
Money=replace(Money,"零元","元")
Money=replace(Money,"零万","万")
Money=replace(Money,"零亿","亿")
Money=replace(Money,"零仟","零")
Money=replace(Money,"零佰","零")
Money=replace(Money,"零拾","零")

dowhilenotinstr(Money,"零零")=0
Money=replace(Money,"零零","零")
loop

response.writeMoney'显示结果
endfunction
%>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值