存在的問題是:大于100,000以上的金額,大寫轉換為拾萬,但要求要轉換成壹拾萬。比如金額為160,000,則大寫為拾陸萬,需要大寫變為壹拾陸萬。
string hz[15],money[2],val,num2,str,str_tmp
int i
hz[1]='壹'
hz[2]='貳'
hz[3]='叁'
hz[4]='肆'
hz[5]='伍'
hz[6]='陸'
hz[7]='柒'
hz[8]='捌'
hz[9]='玖'
hz[10]='拾'
hz[11]='佰'
hz[12]='仟'
hz[13]='萬'
hz[14]='億'
hz[15]='元'
money[1]='角'
money[2]='分'
val=num
do while left(val,1)='0'
val=right(val,len(val) - 1)
loop
if pos(val,'.')<>0 then
num=left(val,pos(val,'.') - 1)
num2=mid(val,pos(val,'.')+1)
end if
str=''
for i=1 to len(num)
str_tmp=mid(num,i,1)
choose case str_tmp
case '1'
str=str+hz[1]
case '2'
str=str+hz[2]
case '3'
str=str+hz[3]
case '4'
str=str+hz[4]
case '5'
str=str+hz[5]
case '6'
str=str+hz[6]
case '7'
str=str+hz[7]
case '8'
str=str+hz[8]
case '9'
str=str+hz[9]
case '0'
str=str+''
end choose
if str_tmp='0' then
if right(str,2)='零' or str='' or i=len(num) then
str=str
else
str=str+'零'
end if
else
choose case len(num) - i+1
case 1
str=str
case 2,6,10
str=str+hz[10]
case 3,7,11
str=str+hz[11]
case 4,8,12
str=str+hz[12] //千
case 5,13
str=str+hz[13] //'萬'
case 9
str=str+'億'
end choose
end if
if len(num) - i+1=9 and mid(num,len(num) - 8,1)='0' then
if right(str,2)='零' then
str=left(str,len(str) - 2)
str=str+'億'
end if
end if
if len(num) - i+1=5 and mid(num,len(num) - 4 ,1)='0' then
if right(str,2)='零' then
str=left(str,len(str) - 2)
str=str+'萬'
end if
end if
next
if right(str,2)='零' then
str=left(str,len(str) - 2)
end if
if left(str,4)='一十' or left(str,4)='壹拾' then
str=right(str,len(str) - 2)
int lpos
lpos=pos(str,'億萬')
if lpos <> 0 then
str=left(str , lpos +1) +mid(str,lpos +4)
end if
end if
if pos(val,'.') =0 then
return str+hz[15]
end if
str = str + hz[15] //點or 元
int il_i
il_i = len(num2)
if il_I > 2 then
il_i = 2
end if
for i= 1 to il_i
str_tmp=mid(num2,i,1)
choose case str_tmp
case '1'
str=str+hz[1]
case '2'
str=str+hz[2]
case '3'
str=str+hz[3]
case '4'
str=str+hz[4]
case '5'
str=str+hz[5]
case '6'
str=str+hz[6]
case '7'
str=str+hz[7]
case '8'
str=str+hz[8]
case '9'
str=str+hz[9]
case '0'
str=str+'零'
end choose
if right(str,2) <> '零' then
str=str+money[i]
end if
next
do while right(str,2) = '零'
str = left(str,len(str) - 2)
loop
return str
uj5u.com熱心網友回復:
自己在return前加上一句:if 傳入的金額 >= 100000 and 傳入的金額 < 200000 then
str = '壹' + str
end if
就可以啦
uj5u.com熱心網友回復:
哈哈 太搞了
uj5u.com熱心網友回復:
向yyoinge學習uj5u.com熱心網友回復:
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/69778.html
標籤:腳本語言
