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

2021-03-31 08:56:58 字數 1286 閱讀 2454

<%

call money(1605893.21)

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

%>

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

將人民幣的數字表示轉化成大寫表示 vb.net版 本 參考chenyu001 將人民幣的數字表示轉化成大寫表示 c 版 改的不多,但願這些改動沒讓原作者發怒 public class chinesenum 輸入字串 private inputstring as string 輸出字串,如果無效則輸出...

將人民幣轉化為大寫

package org.cric.util public class moneychange 段內位置表示 char vunit 段名表示 char digit 數字表示 long midval long value 100 轉化成整形 string valstr string.valueof mi...

數字轉化成大寫金額 C 版

class numprocess if lng 10 lng 100 if lng 100 lng 1000 if lng 1000 lng 10000 if lng 10000 lng 100000000 if lng 100000000 return endregion region 獲取單個數...