將數字轉換成大寫的金額換算函式

2021-03-31 08:56:29 字數 1289 閱讀 4478

<%

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

數字轉換成大寫金額

數字轉換成大寫金額 using system public class numtocaps 將數定轉換大寫金額格式 引數必須小於萬萬億,且不超過兩位小數多過兩位自動擷取兩位 返回大寫金額 public string getcaps decimal d if d 0 if s.length 0 s.l...

數字轉換成大寫金額

數字轉換成大寫金額 例如 new money 200 tostring 貳佰元 namespace skyiv.util catch system.console.writeline 大寫 newmoney m 該類過載的 tostring 方法返回的是大寫金額字串 class money 建構函式...

將金額轉換成大寫漢字

integer li i integer li lendec,li lenint integer li amout flag integer li point string ls amount string string ls single string ls single dx string ls...

將金額轉換成大寫表示

function cny ns else 處理漢字中的語義問題 ns1 str replace 零零零零萬 零零零 零零 零 零 零 implode array reverse list ns1 str replace 零億 零萬 零圓 億 萬 圓 ns1 else 處理小數部分 if empty ...

Java將小寫金額轉換成大寫

工作中遇到金額小寫轉大寫的需求。由於現成的工具包沒有找到此功能。最後搜到 如下 public class test public static string change double v long l math.round v 100 if l 0 string strvalue l i用來控制數...