将数字转换为大写金额

/********************************************************************/
/*函数  : 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
 

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

【最优潮流】直流最优潮流(OPF)课设(Matlab代码实现)内容概要:本文档主要围绕“直流最优潮流(OPF)课设”的Matlab代码实现展开,属于电力系统优化领域的教学与科研实践内容。文档介绍了通过Matlab进行电力系统最优潮流计算的基本原理与编程实现方法,重点聚焦于直流最优潮流模型的构建与求解过程,适用于课程设计或科研入门实践。文中提及使用YALMIP等优化工具包进行建模,并提供了相关资源下载链接,便于读者复现与学习。此外,文档还列举了大量与电力系统、智能优化算法、机器学习、路径规划等相关的Matlab仿真案例,体现出其服务于科研仿真辅导的综合性平台性质。; 适合人群:电气工程、自动化、电力系统及相关专业的本科生、研究生,以及从事电力系统优化、智能算法应用研究的科研人员。; 使用场景及目标:①掌握直流最优潮流的基本原理与Matlab实现方法;②完成课程设计或科研项目中的电力系统优化任务;③借助提供的丰富案例资源,拓展在智能优化、状态估计、微电网调度等方向的研究思路与技术手段。; 阅读建议:建议读者结合文档中提供的网盘资源,下载完整代码与工具包,边学习理论边动手实践。重点关注YALMIP工具的使用方法,并通过复现文中提到的多个案例,加深对电力系统优化问题建模与求解的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值