ASP將數(shù)字轉(zhuǎn)中文數(shù)字(大寫金額)的函數(shù)
下面跟大家分享2種不同函數(shù)的實(shí)現(xiàn)方式。
ASP將數(shù)字轉(zhuǎn)中文數(shù)字金額的函數(shù)一
<% 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 Response.write Money(8200001) %>
ASP阿拉伯?dāng)?shù)字轉(zhuǎn)中文數(shù)字
<%
'################################
'函數(shù)名:阿拉伯?dāng)?shù)字轉(zhuǎn)中文數(shù)字函數(shù)
'################################
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&"萬(wàn)"
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&"萬(wàn)"
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")
%>
到此這篇關(guān)于ASP將數(shù)字轉(zhuǎn)中文數(shù)字(大寫金額)的函數(shù)的文章就介紹到這了,更多相關(guān)ASP 數(shù)字轉(zhuǎn)中文數(shù)字內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
我用ASP寫的m行n列的函數(shù),動(dòng)態(tài)輸出創(chuàng)建TABLE行列
我用ASP寫的m行n列的函數(shù),動(dòng)態(tài)輸出創(chuàng)建TABLE行列...2007-02-02
asp頁(yè)面提示Response 對(duì)象 錯(cuò)誤 ASP 0156 : 80004005 HTTP 頭錯(cuò)誤
訪問(wèn)asp頁(yè)面時(shí)提示Response 對(duì)象 錯(cuò)誤 ASP 0156 : 80004005 HTTP 頭錯(cuò)誤?,行 0 已將 HTTP 頭輸出到客戶端瀏覽器。任何對(duì) HTTP 頭的修改都必須在輸出頁(yè)內(nèi)容之前進(jìn)行。2011-09-09
解決ASP中http狀態(tài)跳轉(zhuǎn)返回錯(cuò)誤頁(yè)的問(wèn)題
這篇文章主要介紹了ASP中http狀態(tài)跳轉(zhuǎn)返回錯(cuò)誤頁(yè)的問(wèn)題的解決方法,感興趣的小伙伴們可以參考一下2015-10-10
ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向
這篇文章主要介紹了ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向,需要的朋友可以參考下2016-12-12
ASP保存遠(yuǎn)程圖片到本地 同時(shí)取得第一張圖片并創(chuàng)建縮略圖的代碼
采集中 或者 在線添加文章中 都可以用到此功能2008-10-10

