VB阿拉伯數字金額轉大寫中文

2021-08-13 23:20:56 字數 1661 閱讀 6459

function mychange(byval myinput)

dim temp, tempa, myinputa, myinputb, myinputc

dim place as string

dim j as integer

place = "分角元拾佰仟萬拾佰仟億拾佰仟萬"

shuzi1 = "壹貳叄肆伍陸柒捌玖"

shuzi2 = "整零元零零零萬零零零億零零零萬"

qianzhui = ""

if val(myinput) = 0 then myinput = 0

if myinput = "" then myinput = 0

if myinput < 0 then qianzhui = "負"

myinput = int(abs(myinput) * 100 + 0.5)

if myinput > 999999999999999# then

mychange = "數字太大了吧???"

exit function

end if

if myinput = 0 then

mychange = "零元零分"

exit function

end if

myinputa = trim(str(myinput))

shuzilong = len(myinputa)

for j = 1 to shuzilong

myinputb = mid(myinputa, j, 1) & myinputb

next

for j = 1 to shuzilong

temp = val(mid(myinputb, j, 1))

if temp = 0 then

myinputc = mid(shuzi2, j, 1) & myinputc

else

myinputc = mid(shuzi1, temp, 1) & mid(place, j, 1) & myinputc

end if

next

shuzilong = len(myinputc)

for j = 1 to shuzilong - 1

if mid(myinputc, j, 1) = "零" then

select case mid(myinputc, j + 1, 1)

case "零", "元", "萬", "億", "整":

myinputc = left(myinputc, j - 1) & mid(myinputc, j + 1, 30)

j = j - 1

end select

end if

next

shuzilong = len(myinputc)

for j = 1 to shuzilong - 1

if mid(myinputc, j, 1) = "億" and mid(myinputc, j + 1, 1) = "萬" then

myinputc = left(myinputc, j) & mid(myinputc, j + 2, 30)

exit for

end if

next

mychange = qianzhui & trim(myinputc)

end function

python 中文大寫轉阿拉伯數字(金額)

輸入 金額的中文大寫 字串 輸出 阿拉伯數字 float或int型 整數部分主要是利用正規表示式進行檢索,將對應項的數字與單位列表的對應項相乘並求和,小數部分也是一樣的手法,但是由於可能存在只有角的情況,正規表示式不好處理,而且角 分這裡涉及的情況並不多,所以我們分離處理 1.初始化引數 2.處理整...

python 中文大寫轉阿拉伯數字(金額)

輸入 金額的中文大寫 字串 輸出 阿拉伯數字 float或int型 整數部分主要是利用正規表示式進行檢索,將對應項的數字與單位列表的對應項相乘並求和,小數部分也是一樣的手法,但是由於可能存在只有角的情況,正規表示式不好處理,而且角 分這裡涉及的情況並不多,所以我們分離處理 1.初始化引數 2.處理整...

js阿拉伯數字轉中文大寫

function dx n if 0 1 9 d d test n return 資料非法 var unit 千百拾億千百拾萬千百拾元角分 str n 00 var p n.indexof if p 0 n n.substring 0,p n.substr p 1,2 unit unit.subst...