p>powerbuilder是当前得到广泛应用的c/s数据库前端开发工具, 在使用pb的过程中,经常遇到要将数字进行英文或中文的大写转换,尤其是在处理金额的时候,本文整理了我在实践中用到的转换方法,提供给大家参考。
一、 英文大写转换
以下是进行英文大写转换的函数内容,函数名为dtoe:
//****** 阿拉伯数--- $#@62;英文数 ******string aa,bb,t1,t2,t3,b,w,cc,a1decimal a=0,c=0,a2integer v,maa="one two three four five six seven "+& "eight nine ten eleven twelve thirteen fourteen fifteen "+& "sixteen seventeeneighteen n.neteen " bb="twenty thirty forty fifty sixty seventyeighty n.nety " //**** 进入时 --- $#@62; tt=round(t,2)t1=string(t)do while pos(t1,",")$#@60; $#@62;0 v=pos(t1,",") t1=mid(t1,1,v - 1)+mid(t1,v+1)loopt2=" "t3=t1if pos(t3,".")$#@60; $#@62;0 then v=pos(t3,".") t1=mid(t3,1,v - 1) t2=mid(t3,v+1)end ift1=space(10 - len(t1))+t1cc=t1b=" "w=" "m=9//*** 整数处理 ***do while m $#@62;0 if mid(cc,m+1,1)=" " then exit end if if integer(mid(cc,m - 1,3))$#@60; $#@62;0 then if m=6 then w=" thousand "+w else if m=3 then w=" million "+w end if end if a=integer(mid(cc,m,2)) //*** 小于 100 的数 *** if a$#@60; $#@62;0 then if a$#@60; 20 then b=righttrim(mid(aa,(a - 1)*9+1,9)) else a1=string(a,00) a2=integer(mid(a1,1,1)) b=righttrim(mid(bb,(a2 - 2)*7+1,7)) a2=integer(mid(a1,2,1)) if a2$#@60; $#@62;0 then b=righttrim(b+"-"+mid(aa,(a2 - 1)*9+1,9)) end if end if w=b+w end if a=integer(mid(cc,m - 1,1))//*** 100--999 的数 *** if a$#@60; $#@62;0 then b=righttrim(mid(aa,(a - 1)*9+1,9))+" hundred " if w$#@60; $#@62;" " and m=9 then b=b+"and " end if w=b+w end if end if m=m - 3loop//*** 小数处理 ***if w=" " then w="zero " end ifif t2$#@60; $#@62;" " and t2$#@60; $#@62;"00" then w=trim(w)+" & "+t2+"/100" end if//*** 结果 --- $#@62; wreturn w
二、中文大写转换
以下是进行中文大写转换的函数内容,函数名为dtormb:
decimal ystring je,x,hz1,hz2,e,h,f,mint b,ay=mjex rim(string(y))b = len(x)-3a = 1e = mid(x,a,1)hz2 = 零壹贰叁肆伍陆柒捌玖hz1 = 仟佰拾亿仟佰拾万仟佰拾元je = do while e$#@60; $#@62;. h = mid(hz2,integer(e)*2+1,2) f = mid(hz1,24 - (b - a)*2 - 1,2) if e$#@60; $#@62;0 or (e=0 and (f=亿 or f=万 or f=元)) then je = trim(je)+h+f else je = trim(je)+h end if a = a+1 e = mid(x,a,1)loop a = a+1e = mid(x,a,1)h = mid(x,a+1,1)if e=0 and h=0 then je = je+整else if e=0 then je = je+零+mid(hz2,integer(h)*2+1,2)+分 else if h=0 then je = je+mid(hz2,integer(e)*2+1,2)+角整 else je = je+mid(hz2,integer(e)*2+1,2) +角+mid(hz2,integer(h)*2+1,2)+分 end if end if end if b = len(je)a = 1do while a$#@60; b m = mid(je,a,4) if m=零元 or m=零万 or m=零亿 or m=零零 then je = mid(je,1,a - 1)+trim(mid(je,a+2,40)) a = a - 2 b = b - 2 end if a = a+2loop return je
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器