人民幣小寫金額轉換為大寫函式

2021-03-31 08:56:58 字數 1278 閱讀 4493

程式**:

<%function money(thenumber)

dim money,i,string1,string2,length,checkp'定義變數

dim one(),onestr()'定義陣列

string1 = "零壹貳叄肆伍陸柒捌玖"

string2 = "萬仟佰拾億仟佰拾萬仟佰拾元角分釐毫"

checkp=instr(thenumber,".")'判斷是否含有小數字

if checkp<>0 then

thenumber=replace(thenumber,".","")'去除小數字

end if

length=len(thenumber) '取得資料長度

redim one(length-1)'重新定義陣列大小

redim onestr(length-1)'重新定義陣列大小

for i=0 to length-1 

one(i)=mid(thenumber,i+1,1) '迴圈取得每一位的數字

one(i)=mid(string1,one(i)+1,1)'迴圈取得數字對應的大寫

if checkp=0 then  

'不含有小數的資料其數字對應的單位

onestr(i)=mid(string2,14-length+i,1) 

else

'含有小數的資料其數字對應的單位

onestr(i)=mid(string2,15-length+i+len(thenumber)-checkp,1)

end if

one(i)=one(i)&onestr(i)'將數字與單位組合

next

money=replace(join(one)," ","") '取得陣列中所有的元素,並連線起來

money=replace(money,"零元","元") 

money=replace(money,"零萬","萬") 

money=replace(money,"零億","億")

money=replace(money,"零仟","零")

money=replace(money,"零佰","零") 

money=replace(money,"零拾","零")

do while not instr(money,"零零")=0 

money=replace(money,"零零","零")

loop

response.write money  '顯示結果

end  function

%>

人民幣小寫金額轉換為大寫函式

程式 functionmoney thenumber dimmoney,i,string1,string2,length,checkp 定義變數 dimone onestr 定義陣列 string1 零壹貳叄肆伍陸柒捌玖 string2 萬仟佰拾億仟佰拾萬仟佰拾元角分釐毫 checkp instr ...

人民幣 小寫金額轉換為大寫金額

標籤 空格分隔 人民幣 小寫金額轉換為大寫金額 jsp div class form group 合計人民幣金額 小寫 js 將輸入的小寫金額 轉換成大寫金額 function arabiatochinese num strunit strunit.substr strunit.length num...

人民幣小寫轉換為大寫

本程式的作用是將人民幣的小寫形式轉換為大寫,例如 呼叫upper 18.5 將會返回字串 壹拾捌圓伍角 package com.zzb.test0 import junit.framework.assert import org.junit.test 測試人民幣小寫轉大寫 author zhengz...