金額大小寫轉換的asp完全無錯版本

2021-04-12 13:51:39 字數 1481 閱讀 4279

<%

dim tmpnum

'從第一張頁面傳過來的小寫金額

tmpnum=request("page1num")

'呼叫並顯示大寫金額

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 = "分角元拾佰仟萬拾佰仟億拾佰仟萬"

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

金額大小寫轉換!

把數字轉換成中文大寫金額,分以下小數截位 param dblmoney double 數字 param blnfull boolean false,2001.30 貳仟零壹元叄角整 true,2001.30 貳仟零佰零拾壹元叄角零分 param bzheng boolean 是否強制末尾加整字 如果...

C 中金額的大小寫轉換

public static string moneytoupper string stramount string strlower null string strupart null string strupper null int itemp 0 保留兩位小數 123.489 123.49 12...

人民幣金額大小寫轉換

大家在編寫涉及到金額的程式的時候,有時候需要將小寫的人民幣金額轉換成大寫表示 下面的 介紹了轉換的實現過程,大家可以參考一下 pragma warning disable 4786 include include include include using std vector using std ...

應用Excel實現大小寫金額轉換

在基本建設審計中,經常需要同時寫明審定工程造價的大小寫金額,如2942635.44元寫為 貳佰玖拾肆萬貳仟陸佰叄拾伍元肆角肆分 388372.80元寫為 叄拾捌萬捌仟叄佰柒拾貳元捌角整 為提高工作效率和保證大寫金額準確性,可使用excel實現大小寫金額轉換。轉換的依據應遵循 會計基礎工作規範 該 規...

人民幣大小寫金額轉換

1.呼叫 convertinttouppercaseamount string value 即可 人民幣大小寫金額轉換 class rmbcapitalization else if currchar 0 else if prevchar 0 else 對結果進行容錯處理 if capresult....