文章詳情頁
ASP將數字轉中文數字(大寫金額)的函數
瀏覽:204日期:2022-06-04 17:03:06
下面跟大家分享2種不同函數的實現方式。
ASP將數字轉中文數字金額的函數一
<% 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 Response.write Money(8200001) %>
ASP阿拉伯數字轉中文數字
<% "################################ "函數名:阿拉伯數字轉中文數字函數 "################################ function chnumstr(num) num=int(abs(num)) strlen=len(num) for i=1 to strlen select case mid(num,i,1) case 1:chnum="一":case 2:chnum="二":case 3:chnum="三" case 4:chnum="四":case 5:chnum="五" case 6:chnum="六":case 7:chnum="七":case 8:chnum="八" case 9:chnum="九":case 0:chnum="零" end select chnumstr=chnumstr&chnum if i=strlen-1 and mid(num,i,1)<>0 then chnumstr=chnumstr&"十" if i=strlen-2 and mid(num,i,1)<>0 then chnumstr=chnumstr&"百" if i=strlen-3 and mid(num,i,1)<>0 then chnumstr=chnumstr&"千" if i=strlen-4 and mid(num,i,1)<>0 then chnumstr=chnumstr&"萬" if i=strlen-5 and mid(num,i,1)<>0 then chnumstr=chnumstr&"十" if i=strlen-6 and mid(num,i,1)<>0 then chnumstr=chnumstr&"百" if i=strlen-7 and mid(num,i,1)<>0 then chnumstr=chnumstr&"千" if i=strlen-8 and mid(num,i,1)<>0 then chnumstr=chnumstr&"萬" next if left(chnumstr,1)="一" then chnumstr=right(chnumstr,len(chnumstr)-1) if right(chnumstr,1)="零" then chnumstr=left(chnumstr,len(chnumstr)-1) end function Response.write chnumstr("84221213") %>
到此這篇關于ASP將數字轉中文數字(大寫金額)的函數的文章就介紹到這了,更多相關ASP 數字轉中文數字內容請搜索以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持!
標簽:
ASP
上一條:asp中將字符串轉數字的函數小結下一條:asp限制域名訪問實現代碼
相關文章:
1. asp(vbs)Rs.Open和Conn.Execute的詳解和區別及&H0001的說明2. ASP.NET MVC遍歷驗證ModelState的錯誤信息3. ASP 信息提示函數并作返回或者轉向4. asp的SQL語句中and和or同時使用的注意事項5. ASP.NET MVC獲取多級類別組合下的產品6. ASP.Net Core(C#)創建Web站點的實現7. ASP基礎入門第六篇(ASP內建對象Request)8. ASP中用select case代替其他語言中的switch case, default用case else9. asp.net core應用docke部署到centos7的全過程10. ASP.NET MVC解決上傳圖片臟數據的方法
排行榜
