[水晶报表]人民币大写转换函数
来源:互联网 发布:linux 更改home空间 编辑:程序博客网 时间:2024/05/01 13:38
当您需要做一个诸如出入库单的报表时,经常会用到人民币总金额的汇总,并希望打印出来的时候有人民币的大写,所以您需要插入一个sum函数来进行合计,那么合计出来的阿拉伯数字的人民币如何转换成中文大写呢?
以下代码将帮你完成人民币大写的转换,您必须添加一个字符串类型的未邦定字段到您的水晶报表,然后将上面您已经sum好的阿拉伯数字作为一个参数传递到下面代码中的函数。即得到了人民币的大写。
Function ConvertRMB (ls as currency) as string dim dx_sz as string dim dx_dw as string dim str_int as string dim str_dec as string dim dx_str as string dim fu as string dim a as string dim b as string dim c as string dim d as string dim b2 as string dim num_int as number dim num_dec as currency dim len_int as number dim i as number dim a_int as number dim pp as number dx_sz="零壹贰叁肆伍陆柒捌玖" dx_dw="万仟佰拾亿仟佰拾万仟佰拾元" if ls<0 then ls=abs(ls) fu="负" else fu="" end if dx_str=CStr (ls) dx_str=Replace (dx_str,"¥","") dx_str=replace(dx_str,",","") if (ls>0) and (ls<1) then dx_str="0"+dx_str pp=InStr (dx_str,".") if pp>0 then str_int=mid(dx_str,1,instr(dx_str,".")-1) else str_int=dx_str end if num_int=ToNumber (str_int) if (ls>0) and (ls<1) then num_dec = ls*100 else num_dec=(ls-num_int)*100 end if str_dec=totext(num_dec) str_dec=replace(str_dec,"¥","") len_int=len(str_int) dx_str="" for i=1 to len_int a=mid(str_int,i,1) a_int=tonumber(a) b=mid(dx_sz,(a_int+1),1) c=mid(dx_dw,(13-len_int+i),1) if dx_str<>"" then d=mid(dx_str,len(dx_str)-1,1) else d="" end if if(b="零") and ((d="零") or (b=b2) 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 dx_str=mid(dx_str,1,len(dx_str)-2) d=mid(dx_str,len(dx_str)-1,2) if((c="元") and (d="万"))or((c="万") and (d="亿")) then c="" end if dx_str=dx_str+b+c b2=b next i '处理金额小于1的情况 if len(dx_str)<2 then dx_str="" if(num_dec<10)and(ls>0) then a_int=tonumber(str_dec) b=mid(dx_sz,(a_int+1),1) if num_dec=0 then dx_str=dx_str+"整" if num_dec>0 then dx_str=dx_str+"零"+b+"分" end if if num_dec>=10 then a_int=tonumber(mid(str_dec,1,1)) a=mid(dx_sz,(a_int+1),1) a_int=tonumber(mid(str_dec,2,1)) b=mid(dx_sz,(a_int+1),1) if a<>"零" then a=a+"角" if b<>"零" then b=b+"分" else b="" dx_str=dx_str+a+b end if if ls=0 then dx_str="零元整" dx_str=fu+dx_str dx_str=replace(dx_str,"零亿","亿") dx_str=replace(dx_str,"零万","万") dx_str=replace(dx_str,"零千","千") dx_str=replace(dx_str,"零元","元") ConvertRMB =dx_strEnd Function
该文章转载自网络大本营:http://www.xrss.cn/Dev/DotNet/2007102817215.Html
- 水晶报表人民币大写转换函数
- [水晶报表]人民币大写转换函数
- 水晶报表金额大写函数
- PHP人民币大写转换函数
- 水晶报表人民币
- 人民币小写转换为大写函数
- 人民币大写转换函数(JavaScript)javascript
- PB实现人民币大写转换函数
- ASP.NET 实现人民币大写转换函数
- 把货币金额转换成大写的函数(水晶报表BASIC语言版)
- 人民币大写转换
- 人民币大写转换
- 转换大写人民币
- c#人民币大写转换
- 人民币转换成大写
- 人民币大写的转换
- 【pascal】人民币大写转换
- 人民币大写金额转换
- Pro ASP.NET 2.0 in VB 2005, Special Edition
- [VB.NET]连接数据库(一)
- [VB.NET]连接数据库(二)
- Pro ASP.NET 2.0 in C# 2005, Special Edition
- [VB.NET]打印和打印预览功能
- [水晶报表]人民币大写转换函数
- [VB.NET]MP3播放器
- PowerPoint 2007 for Starters: The Missing Manual [ILLUSTRATED]
- Sql_Server中如何判断表中某列是否存在
- [VB.NET]随机图形
- [VB.NET]简单图形
- Rails for Java Developers [ILLUSTRATED]
- [VB.NET]小闹钟
- 这个冬天不太冷