1
2dim tmpnum
3'从第一张页面传过来的小写金额
4tmpnum=request("page1num")
5'调用并显示大写金额
6response.write rmb(cdbl(tmpnum))
7response.end
common.asp
1
2Function rmb(num)
3
4num = FormatNumber(num, 2)
5Dim numList
6Dim rmbList
7Dim numLen
8Dim numChar
9Dim numstr
10Dim n
11Dim n1, n2
12Dim hz
13numList = "零壹贰叁肆伍陆柒捌玖"
14rmbList = "分角元拾佰仟万拾佰仟亿拾佰仟万"
15
16If num > 9999999999999.99 Then
17rmb = "超出范围的人民币值"
18Exit Function
19End If
20
21numstr = CStr(num * 100)
22numLen = Len(numstr)
23n = 1
24Do While n <= numLen
25numChar = CInt(Mid(numstr, n, 1))
26n1 = Mid(numList, numChar + 1, 1)
27n2 = Mid(rmbList, numLen - n + 1, 1)
28If Not n1 = "零" Then
29hz = hz + CStr(n1) + CStr(n2)
30Else
31If n2 = "亿" Or n2 = "万" Or n2 = "元" Or n1 = "零" Then
32Do While Right(hz, 1) = "零"
33hz = Left(hz, Len(hz) - 1)
34Loop
35End If
36If (n2 = "亿" Or (n2 = "万" And Right(hz, 1) <> "亿") Or n2 = "元") Then
37hz = hz + CStr(n2)
38Else
39If Left(Right(hz, 2), 1) = "零" Or Right(hz, 1) <> "亿" Then
40hz = hz + n1
41End If
42End If
43End If
44n = n + 1
45Loop
46Do While Right(hz, 1) = "零"
47hz = Left(hz, Len(hz) - 1)
48Loop
49If Right(hz, 1) = "元" Then
50hz = hz + "整"
51End If
52rmb = hz
53End Function
这个版本解决了小数位不能到分的问题,处理方式符合会计方式!