将数字转换为大写金额
2011-11-06 22:55
295 查看
/********************************************************************/
/*函数 : 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
//有些地方写得不是很严密,希望提出好的意见!
/*函数 : 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
//有些地方写得不是很严密,希望提出好的意见!
相关文章推荐
- 将数字金额转换为人民币大写字符串
- C语言 阿拉伯数字转换为汉语大写数字金额程序分析及源码
- ABAP--将数字金额转换为人民币大写字符串(增加UNICODE版本)
- js 数字金额大小写转换成中文大写
- 阿拉伯数字金额转换为中文大写之存储过程(更新版)
- C#把数字转换成大写金额的代码实例
- 将数字金额转换为对应的中文大写金额
- JS实现数字金额转换为大写金额
- 数字转换成金额大写的小程序
- 小写数字金额转换成大写金额(C#)
- C#小写数字金额转换成大写人民币金额的算法
- ABAP--将数字金额转换为人民币大写字符串(增加UNICODE版本)
- 用JavaScript将数字转换为大写金额
- Java中实现数字金额到中文大写字符的转换!!
- C#数字金额转换大写金额
- 把阿拉伯数字的金额转换为中文大写数字
- java实现数字金额转换中文大写金额
- 输入数字转换成中文大写(钱,财务计算金额)
- 将金额转换到大写数字的C#函数
- 将金额数字转换为汉字大写金额