疯狂的VFPER之数值转换为金额大写
一晃真正用VFP写程序也已6年多了,大大小小也做了几十个系统,曾经有多少个日夜坐在电脑前敲打着空格、回车...,突然发现我在论坛上回贴的多,发贴的少,决定痛改前非:)...闲话少说,言归正传,我会陆续将我的部份VFP代码给大家分享(并不一定都是我的原创,有些是在其他VFPER的代码上改的)。疯狂的VFPER之数值转换为金额大写
将以下代码存为RMB.prg,在其它地方调用,如?RMB(123.45)。
Lparameters tnMoney
Private lcMoney,lnMoney,i,lcReturnValue
Local lcMoney,lnMoney,i,lcReturnValue
lcMoney = Iif(tnMoney<0,"负","")
lnMoney = Round(Abs(tnMoney)*100,0)
For i = Len(Alltrim(Str(lnMoney,15)))-1 To 0 Step -1
lcMoney = lcMoney+Subs("零壹贰叁肆伍陆柒捌玖",Int(Round(lnMoney/10^i,10))*2+1,2)+Subs("分角元拾佰仟万拾佰仟亿拾佰仟万",i*2+1,2)
lnMoney = Mod(lnMoney,10^i)
Endfor
lcMoney = Strtran(Strtran(Strtran(Strtran(Strtran(lcMoney,"零仟","零"),"零佰","零"),"零拾","零"),"零角","零"),"零分","整")
lcMoney = Strtran(Strtran(Strtran(Strtran(Strtran(lcMoney,"零零","零"),"零零","零"),"零亿","亿"),"零万","万"),"零元","元")
lcReturnValue = Iif(lcMoney="整","零元整",Strtran(Strtran(lcMoney,"亿万","亿"),"零整","整"))
Return (lcReturnValue)