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

來源:互聯網
上載者:User
程式碼:
<%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
%>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.