Visual Basic語法:
dim sa,sb,sc as string
sa=cstr({命令.amt})
sa=replace(sa,",","")

dim i,j,p as  Number
i=1
j=len(sa)
sb=""

p=InStrRev (sa,"." )
if right(sa,3)=".00" then
j=j-2
elseif right(sa,1)="0" then
j=j-1
end if

do while i<j+1
   sc=mid(sa,i,1)
select case sc
case "0"
sb=sb+"零"
case "1"
sb=sb+"壹"
case "2"
sb=sb+"貳"
case "3"
sb=sb+"叁"
case "4"
sb=sb+"肆"
case "5"
sb=sb+"伍"
case "6"
sb=sb+"陸"
case "7"
sb=sb+"柒"
case "8"
sb=sb+"捌"
case "9"
sb=sb+"玖"
case else
sb=sb+"元"
end select
if i=p+1 then
   sb=sb+"角"
elseif i=p+2 then
   sb=sb+"分"
end if

select case p-i
case 9
if right(sb,1)<>"零" then sb=sb+"億"
case 8
if right(sb,1)<>"零" then sb=sb+"仟"
case 7
if right(sb,1)<>"零" then sb=sb+"百"
case 6
if right(sb,1)<>"零" then sb=sb+"拾"
case 5
if right(sb,1)<>"零" then sb=sb+"萬"
case 4
if right(sb,1)<>"零" then sb=sb+"仟"
case 3
if right(sb,1)<>"零" then sb=sb+"百"
case 2
if right(sb,1)<>"零" then sb=sb+"拾"
case else
end select

i=i+1
loop
if right(sa,3)=".00" then sb=sb+"整"
sb=replace(sb,"零零","")
sb=replace(sb,"零元","元")
formula =sb

posted on 2007-12-08 14:50  小哈  阅读(423)  评论(0编辑  收藏  举报