0 then retval=retval&y((strlen-i) mod 4)'如果大于零,加入十进位字符 retval=replace(retval,z(0)&z(0),z(0))'出现两个零只留一个 if ((strlen-i) mod 4)=0 and right(retval,1)=z(0) then retval=left(retval,len(retval)-1)'每四位加入进阶 if ((strlen-i) mod 4)=0 then retval=retval&x(int((strlen-i)/4))'把最后的零去掉 next int2chn=retval end function '小写金额转大写 Function UMoney(money) Dim lnP,Prc,Tmp,NoB,Dx,Xx,Zhen Dim China : China = "分角元拾佰仟万拾佰仟亿" Dim str: str = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖") Zhen = True money = FormatNumber(money, 2) Prc = CStr(money) Prc = Replace(Prc, ",", "") lnP = Len(Prc) For i = lnP - 1 To 1 Step -1 If Mid(Prc, i, 1) = "." Then Select Case lnP - i Case 1 Prc = Replace(Prc, ".", "") + "0" Case 2 Prc = Replace(Prc, ".", "") End Select Zhen = False Exit For End If Next If Zhen Then Prc = Prc + "00" lnP = Len(Prc) For i = 1 To lnP Tmp = str(Mid(Prc, i, 1)) & Tmp Next UMoney = "" fy = 1 For i = 1 To lnP Xx = Mid(Tmp, i, 1) Dx = Mid(China, i, 1) If Xx "零" Then UMoney = Xx & Dx & UMoney f = 1 Else If i = 3 Then UMoney = Dx & UMoney End If If i = 7 Then UMoney = Dx & UMoney End If If f Then UMoney = "零" & UMoney End If f = 0 End If Next If Zhen Then UMoney = UMoney + "整" UMoney = Replace(UMoney, "零万", "万") UMoney = Replace(UMoney, "零元", "元") End Function ,Bullcn'Blog - 分享、交流、进步。" /> 小写数字转大写 - Bullcn'Blog

小写数字转大写


'小写数字转大写
function int2chn(n)
dim i,j,k,strlen,retval,x,y,z,str
z=array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖")
y=array("","拾","佰","仟")
x=Array("","万","亿","万万亿")
strlen=len(n)
str1=n
for i= 1 to strlen
j=mid(str1,i,1)
retval=retval&z(j)
if j>0 then retval=retval&y((strlen-i) mod 4)'如果大于零,加入十进位字符
retval=replace(retval,z(0)&z(0),z(0))'出现两个零只留一个
if ((strlen-i) mod 4)=0 and right(retval,1)=z(0) then retval=left(retval,len(retval)-1)'每四位加入进阶
if ((strlen-i) mod 4)=0 then retval=retval&x(int((strlen-i)/4))'把最后的零去掉
next
int2chn=retval
end function

'小写金额转大写
Function UMoney(money)
Dim lnP,Prc,Tmp,NoB,Dx,Xx,Zhen
Dim China : China = "分角元拾佰仟万拾佰仟亿"
Dim str: str = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖")    
Zhen = True    
money = FormatNumber(money, 2)    
Prc = CStr(money)    
Prc = Replace(Prc, ",", "")        
lnP = Len(Prc)    
For i = lnP - 1 To 1 Step -1        
If Mid(Prc, i, 1) = "." Then            
Select Case lnP - i                
Case 1                    
Prc = Replace(Prc, ".", "") + "0"                
Case 2                    
Prc = Replace(Prc, ".", "")            
End Select            
Zhen = False            
Exit For        
End If    
Next    
If Zhen Then Prc = Prc + "00"    
lnP = Len(Prc)    
For i = 1 To lnP        
Tmp = str(Mid(Prc, i, 1)) & Tmp    
Next    
UMoney = ""    
fy = 1    
For i = 1 To lnP        
Xx = Mid(Tmp, i, 1)        
Dx = Mid(China, i, 1)                
If Xx <> "零" Then            
UMoney = Xx & Dx & UMoney            
f = 1        
Else            
If i = 3 Then            
UMoney = Dx & UMoney            
End If                    
If i = 7 Then                
UMoney = Dx & UMoney            
End If            
If f Then                
UMoney = "零" & UMoney            
End If            
f = 0        
End If    
Next    
If Zhen Then UMoney = UMoney + "整"    
UMoney = Replace(UMoney, "零万", "万")    
UMoney = Replace(UMoney, "零元", "元")
End Function

文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: 大写
相关日志:
评论: 0 | 引用: 0 | 查看次数: 386
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 20 字 | UBB代码 关闭 | [img]标签 关闭