明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

將人民幣的數(shù)字轉(zhuǎn)化成大寫表示

[摘要]<%call Money(22222222222) function Money(thenumber) dim Money,i,String1,String2,length,checkp'定義變量 dim one(),onestr()'定義數(shù)組 String1 = &q...

 <%call Money(22222222222)
  function Money(thenumber)
  dim Money,i,String1,String2,length,checkp'定義變量
  dim one(),onestr()'定義數(shù)組 String1 = "零壹貳叁肆伍陸柒捌玖"
  String2 = "萬(wàn)仟佰拾億仟佰拾萬(wàn)仟佰拾元角分厘毫"   checkp=instr(thenumber,".")'判斷是否含有小數(shù)位
   if checkp<>0 then
   thenumber=replace(thenumber,".","")'去除小數(shù)位
   end if   length=len(thenumber) '取得數(shù)據(jù)長(zhǎng)度
   redim one(length-1)'重新定義數(shù)組大小
   redim onestr(length-1)'重新定義數(shù)組大小  for i=0 to length-1      one(i)=mid(thenumber,i+1,1) '循環(huán)取得每一位的數(shù)字
     one(i)=mid(string1,one(i)+1,1)'循環(huán)取得數(shù)字對(duì)應(yīng)的大寫              if checkp=0 then 
                                                  '不含有小數(shù)的數(shù)據(jù)其數(shù)字對(duì)應(yīng)的單位
                   onestr(i)=mid(string2,14-length+i,1)
                else
                                               '含有小數(shù)的數(shù)據(jù)其數(shù)字對(duì)應(yīng)的單位
                onestr(i)=mid(string2,15-length+i+len(thenumber)-checkp,1)
                end if
 
   one(i)=one(i)&onestr(i)'將數(shù)字與單位組合
  next    Money=replace(join(one)," ","") '取得數(shù)組中所有的元素,并連接起來(lái)
    Money=replace(Money,"零元","元")
    Money=replace(Money,"零萬(wàn)","萬(wàn)")
    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  '顯示結(jié)果
  end  function
  %>(出處:pconline)