如何把数字(currency)转化成大写的汉字串

hong99 2003-12-11 09:14:42
如何把数字(currency)转化成大写的汉字串.
数字最大长度为11位(11.2)
比如123,转化成壹佰贰拾叁元.

有这方面的,请帮忙.我先谢了.
...全文
78 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
banalman 2003-12-18
  • 打赏
  • 举报
回复
转载:
int i,li_lendec,li_lenint
int li_amout_flag
string ls_numstr,a,b,c,d,bbak
string ls_dxint[13],ls_dxdec[2],ls_sz[13]
string ls_dxstr="万仟佰拾亿仟佰拾万仟佰拾元"
string ls_szstr="零壹贰叁肆伍陆柒捌玖"
string return_value

if ad_amout < 0.00 then
ad_amout = abs(ad_amout)
li_amout_flag = 1
end if

ls_numstr=string(ad_amout,"#0.00")
li_lenint=len(mid(ls_numstr,1,pos(ls_numstr,'.') - 1))
//messagebox('',li_lenint)
/*if right(ls_numstr,2)='00' then
li_lendec=0
else*/
// li_lendec=2
//end if

for i=1 to 13
ls_dxint[i]=mid(ls_dxstr,26 - i*2+1,2)
if i<11 then
ls_sz[i]=mid(ls_szstr,i*2 - 1,2)
else
ls_sz[i]=" "
end if
next
ls_dxdec[1]="角"
ls_dxdec[2]="分"
ls_dxstr=" "

for i = 1 to li_lenint
a = mid(mid(ls_numstr,1,li_lenint),i,1)
b = ls_sz[integer(a)+1]
c = ls_dxint[li_lenint - i +1]
/*if ls_dxstr<>" " then
d = mid(ls_dxstr,len(ls_dxstr) - 1 ,2)
else
d = " "
end if
if b="零" and (d="零" or b=bbak or c="元" or c="万" or c="亿") then b=""
if a="0" and c<>"元" and c<>"万" and c<>"亿" then c=""
if (c="元" or c="万" or c="亿") and d="零" and a="0" then
ls_dxstr=mid(ls_dxstr,1,len(ls_dxstr) - 2)
d = mid(ls_dxstr,len(ls_dxstr) - 1,2)
if (c="元" and d="万" or c="万"and d="亿") then c=""
end if*/
ls_dxstr=ls_dxstr + b + c
//bbak = b
next
//messagebox('',ls_dxstr)
for i=1 to 2
a = mid (mid(ls_numstr,li_lenint+2,2),i,1)
b=ls_sz[integer(a) + 1]
ls_dxstr=ls_dxstr+b+ls_dxdec[i]
next
ls_dxstr="¥¥"+trim(ls_dxstr)

if position > len(ls_dxstr) then
return return_value
else
return_value=left(right(ls_dxstr,position),2)
end if

return return_value
poemlake 2003-12-11
  • 打赏
  • 举报
回复
这是我以前的一个函数,是在别人的函数基础上改的
两个参数 ad_mount (要黑转换的数字) position(所要取得的字符的位置)
返回并不是整个的大写,你可以改一下
//------------------------------------------------//
// 将金额转为大写
//------------------------------------------------//

int i,li_lendec,li_lenint
int li_amout_flag
string ls_numstr,a,b,c,d,bbak
string ls_dxint[13],ls_dxdec[2],ls_sz[13]
string ls_dxstr="万仟佰拾亿仟佰拾万仟佰拾元"
string ls_szstr="零壹贰叁肆伍陆柒捌玖"
string return_value

if ad_amout < 0.00 then
ad_amout = abs(ad_amout)
li_amout_flag = 1
end if

ls_numstr=string(ad_amout,"#0.00")
li_lenint=len(mid(ls_numstr,1,pos(ls_numstr,'.') - 1))
//messagebox('',li_lenint)
/*if right(ls_numstr,2)='00' then
li_lendec=0
else*/
// li_lendec=2
//end if

for i=1 to 13
ls_dxint[i]=mid(ls_dxstr,26 - i*2+1,2)
if i<11 then
ls_sz[i]=mid(ls_szstr,i*2 - 1,2)
else
ls_sz[i]=" "
end if
next
ls_dxdec[1]="角"
ls_dxdec[2]="分"
ls_dxstr=" "

for i = 1 to li_lenint
a = mid(mid(ls_numstr,1,li_lenint),i,1)
b = ls_sz[integer(a)+1]
c = ls_dxint[li_lenint - i +1]
/*if ls_dxstr<>" " then
d = mid(ls_dxstr,len(ls_dxstr) - 1 ,2)
else
d = " "
end if
if b="零" and (d="零" or b=bbak or c="元" or c="万" or c="亿") then b=""
if a="0" and c<>"元" and c<>"万" and c<>"亿" then c=""
if (c="元" or c="万" or c="亿") and d="零" and a="0" then
ls_dxstr=mid(ls_dxstr,1,len(ls_dxstr) - 2)
d = mid(ls_dxstr,len(ls_dxstr) - 1,2)
if (c="元" and d="万" or c="万"and d="亿") then c=""
end if*/
ls_dxstr=ls_dxstr + b + c
//bbak = b
next
//messagebox('',ls_dxstr)
for i=1 to 2
a = mid (mid(ls_numstr,li_lenint+2,2),i,1)
b=ls_sz[integer(a) + 1]
ls_dxstr=ls_dxstr+b+ls_dxdec[i]
next
ls_dxstr="¥¥"+trim(ls_dxstr)

if position > len(ls_dxstr) then
return return_value
else
return_value=left(right(ls_dxstr,position),2)
end if

return return_value
bunnysky 2003-12-11
  • 打赏
  • 举报
回复
UP
TGWall 2003-12-11
  • 打赏
  • 举报
回复
看一看这个吧,前段时间讨论得热火朝天的
http://expert.csdn.net/Expert/topic/2148/2148196.xml?temp=.4854853
intuition444 2003-12-11
  • 打赏
  • 举报
回复
我有一个PB8的源码,邮箱留下,我发给你
sundayblue 2003-12-11
  • 打赏
  • 举报
回复
这需要自己写程序,好象论坛里有相关的帖子,自己搜一搜
intuition444 2003-12-11
  • 打赏
  • 举报
回复
发完了!
hong99 2003-12-11
  • 打赏
  • 举报
回复
intuition444(直觉):我的邮箱是:hong_ley@163.com
先谢谢了.

1,077

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧