# 將人民幣的數字轉化成大寫表示

callMoney(22222222222)
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 '顯示結果
end function
%>

## E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

## Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

## Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth \$300-1200 USD