将数字转换为大写金额

/********************************************************************/
/*函数  : f_conver_number_chinese                                                                                */
/*参数  : adec_money  将要转换为大写金额的数字                                                                */
/*返回值: string                                                                                                                */
/*撰写人: huwenbin 2009/06/5                                                                                         */
/********************************************************************/

 

string ls_money_unit,ls_money,ls_nuit,ls_badge
int li_long,li_i
ls_money = trim(string(round(adec_money,2)))

do while left(ls_money,1) = '0'
 ls_money = mid(ls_money,2)
loop

li_long = len(ls_money)

for li_i = 1 to li_long
 ls_nuit = right(ls_money,li_i)
 ls_nuit = left(ls_nuit,1)
 
 choose case ls_nuit
  case '.'
   ls_nuit = ''
  case '1'
   ls_nuit = '壹'
  case '2'
   ls_nuit = '贰'
  case '3'
   ls_nuit = '叁'
  case '4'
   ls_nuit = '肆'
  case '5'
   ls_nuit = '伍'
  case '6'
   ls_nuit = '陆'
  case '7'
   ls_nuit = '柒'
  case '8'
   ls_nuit = '捌'
  case '9'
   ls_nuit = '玖'
  case '0'
   ls_nuit = '零' 
 end choose
 
 choose case li_i
  case 1
   ls_badge = '分'
  case 2
   ls_badge = '角'
  case 3
   ls_badge = ''
  case 4
   ls_badge = '元'
  case 5,9,13
   ls_badge = '拾'
  case 6,10,14
   ls_badge = '佰'
  case 7,11,15
   ls_badge = '仟'
  case 8
   ls_badge = '万'  
  case 12
   ls_badge = '亿'  
 end choose
 
 if li_i = 4 and ls_nuit = '零' then
    ls_money_unit = '元' + ls_money_unit
 end if
 
 if pos(ls_money_unit,'万') = 0 then
    if li_i > 7 and ls_nuit = '零' then
       ls_money_unit = '万' + ls_money_unit
    end if
 end if
  
 if pos(ls_money_unit,'亿') = 0 then
   if li_i > 11 and ls_nuit = '零' then
     ls_money_unit = '亿' + ls_money_unit
   end if
 end if
  
 if ls_nuit <> '零' then
    ls_money_unit = ls_nuit + ls_badge + ls_money_unit
 else
    ls_money_unit = ls_nuit + ls_money_unit
 end if
 
 int pos1,pos2,pos3,pos4
 
 pos1 = pos(ls_money_unit,'零元')
 if pos1 > 0 then
    ls_money_unit = replace(ls_money_unit,pos1,4,'元零')
 end if
 
 pos2 = pos(ls_money_unit,'零万')
 if pos2 > 0 then
    ls_money_unit = replace(ls_money_unit,pos2,4,'万零')
 end if
 
 pos3 = pos(ls_money_unit,'零亿')
 if pos3 > 0 then
    ls_money_unit = replace(ls_money_unit,pos3,4,'亿零')
 end if
 
 pos4 = pos(ls_money_unit,'零零')
 if pos4 > 0 then
    ls_money_unit = replace(ls_money_unit,pos4,2,'')
 end if
next


if right(ls_money_unit, 2) = '零' then
  ls_money_unit = left(ls_money_unit,len(ls_money_unit) - 2)
end if

 

if right(ls_money_unit, 2) = '元' then
    ls_money_unit = ls_money_unit + '整'
end if

 

return ls_money_unit
 

//有些地方写得不是很严密,希望提出好的意见!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值