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

2021-08-29 03:15:50 字數 1240 閱讀 4264

程式**:

<%functionmoney(thenumber)

dimmoney,i,string1,string2,length,checkp'定義變數

dimone(),onestr()'定義陣列

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

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

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

ifcheckp<>0then

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

endif

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

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

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

fori=0tolength-1

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

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

ifcheckp=0then

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

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

else

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

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

endif

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,"零拾","零")

dowhilenotinstr(money,"零零")=0

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

loop

response.writemoney'顯示結果

endfunction

%>

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

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

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

標籤 空格分隔 人民幣 小寫金額轉換為大寫金額 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...