极品分享

asp金额数字转换为大写汉字

<form name="form1" method="post" action="demo.asp">
<input type="text" name="page1num" id="page1num" value="<%=request("page1num")%>">
<input type="submit" name="button" id="button" value="提交">
</form>


<%
dim tmpnum
tmpnum=request("page1num")
response.write rmb(cdbl(tmpnum))
response.end

Function rmb(num)
 num = FormatNumber(num, 2)
 Dim numList
 Dim rmbList
 Dim numLen
 Dim numChar
 Dim numstr
 Dim n
 Dim n1, n2
 Dim hz
 numList = "零壹贰叁肆伍陆柒捌玖"
 rmbList = "分角元拾佰仟万拾佰仟亿拾佰仟万"
 If num > 9999999999999.99 Then
  rmb = "超出范围的人民币值"
  Exit Function
 End If
 numstr = CStr(num * 100)
 numLen = Len(numstr)
 n = 1
 Do While n <= numLen
  numChar = CInt(Mid(numstr, n, 1))
  n1 = Mid(numList, numChar + 1, 1)
  n2 = Mid(rmbList, numLen - n + 1, 1)
  If Not n1 = "零" Then
   hz = hz + CStr(n1) + CStr(n2)
  Else
   If n2 = "亿" Or n2 = "万" Or n2 = "元" Or n1 = "零" Then
    Do While Right(hz, 1) = "零"
    hz = Left(hz, Len(hz) - 1)
    Loop
   End If
   If (n2 = "亿" Or (n2 = "万" And Right(hz, 1) <> "亿") Or n2 = "元") Then
    hz = hz + CStr(n2)
   Else
    If Left(Right(hz, 2), 1) = "零" Or Right(hz, 1) <> "亿" Then
     hz = hz + n1
    End If
   End If
  End If
  n = n + 1
 Loop
 Do While Right(hz, 1) = "零"
  hz = Left(hz, Len(hz) - 1)
 Loop
 If Right(hz, 1) = "元" Then
  hz = hz + "整"
 End If
 rmb = hz
End Function

%>

 

 

ASP小写数字转大写

'小写数字转大写
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
2012-10-20 0 /
ASP学习
/
标签: 

评论回复

回到顶部