日期:2014-05-17  浏览次数:20912 次

转换大写金额
<table border=0" width="100%" id="table8">
<tr>
<td width="50%">
<p align="center">价格总计:RMB<%=formatnumber(totalprice,2)%></td>
<td width="50%">
<p align="left">大写:</td>
</tr>
</table>
------------------------------------------------------------
我想把左边的价格总计的数字,转换成大写的金额,请高手帮忙,谢谢.代码如上:

------解决方案--------------------
<%
totalprice = "1232323.31232"
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 
response.write rmb(totalprice)
%>
------解决方案--------------------
'**********************************************************************************
'函数名称:Money()
'函数功能:人民币小写转大写
'函数返回值:Str
'作者:蒋三德
'作用范围:所有
'**********************************************************************************
Public Function Money(rmb)
cRmb1 = "仟佰拾万仟佰拾亿仟佰拾万仟佰拾元角分"
cRmb2 = "壹贰叁肆伍陆柒捌玖"
cRmb = TRIM(CSTR(ROUND(Rmb,2)*100))
If right(crmb,1)="0" Then
cReChsRmb = "整"
nZero = 0
Else
cReChsRmb = ""
nZero = 1
End If

FOR i = LEN(cRmb) To 1 Step -1
cNum = Mid(cRmb,i,1)
IF Not cNum="0" Then
cReChsRmb = Mid(cRmb2,INT(cInt(Mid(cRmb,i,1))),1) + Mid(cRmb1,I-LEN(cRmb)+18,1) + cReChsRmb
nZero = 1
Else
cChsNum2 = Mid(cRmb1,I-LEN(cRmb)+18,1)
If InStr(cChsNum2,"亿") >0 And InStr(cChsNum2,"万") >0 And InStr(cChsNum2,"元") >0 Then
If cChsNum2 = "亿" and LEFT(cReChsRmb,2) = "万" Then
cReChsRmb = cChsNum2 + SUBSTRC(cReChsRmb,2)
Else 
cReChsRmb= cChsNum2 + cReChsRmb
End If
Else
If nZero=1 Then
cReChsRmb = "零" + cReChsRmb
Else
cReChsRmb = cReChsRmb
End If
End If
nZero = 0
End If
Next
If InStr(cReChsRmb,"元") <= 0 Then
cReChsRmb =