〖打印本页〗〖打印选项〗 |
金额大小写转换的ASP版 |
01 <form name= "form1" method= "post" action= "Submit.asp" > 02 <input type= "text" name= "page1num" > 03 <input type= "submit" name= "Submit" value= "提交" > 04 </form> 05 06 ------以下是Submit.asp的代码--------- 07 <% 08 dim tmpnum 09 '从第一张页面传过来的小写金额 10 tmpnum=request("page1num") 11 '调用并显示大写金额 12 response.write rmb(cdbl(tmpnum)) 13 response.end 14 %> 15 <% 16 Function rmb(num) 17 num = FormatNumber(num, 2) 18 dim numList 19 dim rmbList 20 dim numLen 21 dim numChar 22 dim numstr 23 dim n 24 dim n1, n2 25 dim hz 26 numList = "零壹贰叁肆伍陆柒捌玖" 27 rmbList = "分角元拾佰仟万拾佰仟亿拾佰仟万" 28 If num > 9999999999999.99 Then 29 rmb = "超出范围的人民币值" 30 Exit Function 31 End If 32 33 numstr = CStr(num * 100) 34 numLen = Len(numstr) 35 n = 1 36 Do While n <= numLen 37 numChar = CInt(Mid(numstr, n, 1)) 38 n1 = Mid(numList, numChar + 1, 1) 39 n2 = Mid(rmbList, numLen - n + 1, 1) 40 If Not n1 = "零" Then 41 hz = hz + CStr(n1) + CStr(n2) 42 Else 43 If n2 = "亿" Or n2 = "万" Or n2 = "元" Or n1 = "零" Then 44 Do While Right(hz, 1) = "零" 45 hz = Left(hz, Len(hz) - 1) 46 Loop 47 End If 48 If (n2 = "亿" Or (n2 = "万" And Right(hz, 1) <> "亿" ) Or n2 = "元") Then 49 hz = hz + CStr(n2) 50 Else 51 If Left(Right(hz, 2), 1) = "零" Or Right(hz, 1) <> "亿" Then 52 hz = hz + n1 53 End If 54 End If 55 End If 56 n = n + 1 57 Loop 58 Do While Right(hz, 1) = "零" 59 hz = Left(hz, Len(hz) - 1) 60 Loop 61 If Right(hz, 1) = "元" Then 62 hz = hz + "整" 63 End If 64 rmb = hz 65 End Function 66 %> 文章作者:未知 |