金額大小寫(xiě)轉(zhuǎn)換的asp完全無(wú)錯(cuò)版本
發(fā)表時(shí)間:2023-08-20 來(lái)源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]<!--#include file=common.asp--><%dim tmpnum'從第一張頁(yè)面?zhèn)鬟^(guò)來(lái)的小寫(xiě)金額tmpnum=request("page1nu...
<!--#include file=common.asp-->
<%
dim tmpnum
'從第一張頁(yè)面?zhèn)鬟^(guò)來(lái)的小寫(xiě)金額
tmpnum=request("page1num")
'調(diào)用并顯示大寫(xiě)金額
response.write rmb(cdbl(tmpnum))
response.end
%>
common.asp
<%
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 = "分角元拾佰仟萬(wàn)拾佰仟億拾佰仟萬(wàn)"
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 = "萬(wàn)" Or n2 = "元" Or n1 = "零" Then
Do While Right(hz, 1) = "零"
hz = Left(hz, Len(hz) - 1)
Loop
End If
If (n2 = "億" Or (n2 = "萬(wàn)" 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
%>
這個(gè)版本解決了小數(shù)位不能到分的問(wèn)題,處理方式符合會(huì)計(jì)方式!