转换
如何将数字转换成中文大写 如:1245.00 ==》 壹仟贰佰肆拾伍元整
程序代码:
Procedure RmbDx Parameter my_n If my_n<0 FC='负' Else FC='' Endif yjf="分角元拾佰仟万拾佰仟亿拾佰仟" s_str="[零分][零角][零拾][零佰][零仟][零零]" d_str="[零亿][零万][零元]" shuzi="零壹贰叁肆伍陆柒捌玖" sss=Alltrim(Str(Int(my_n*100), 30)) dx="" For I=1 To Len(sss) c=Substr(sss,Len(sss)-I+1,1) dx=Substr(shuzi,Val(c)*2+1,2)+Substr(yjf,I*2-1,2)+dx Endfor dxl=Len(dx) myexit=.T. Do While .T. For ii=1 To dxl Step 2 If Substr(dx,ii,4)$s_str.And.Len(Substr(dx,ii,4))=4 myexit=.F. Exit Else myexit=.T. Endif Endfor If myexit=.F. dx=Substr(dx,1,ii+1)+Substr(dx,ii+4,dxl-(ii+3)) dxl=Len(dx) Else Exit Endif Enddo * dxl=Len(dx) myexit=.T. Do While .T. For ii=1 To dxl Step 2 If Substr(dx,ii,4)$d_str.And.Len(Substr(dx,ii,4))=4 myexit=.F. Exit Else myexit=.T. Endif Endfor If myexit=.F. dx=Substr(dx,1,ii-1)+Substr(dx,ii+2,dxl-(ii+1)) dxl=Len(dx) Else Exit Endif Enddo yw_wz=At("亿万",dx) If yw_wz>0 dx=Substr(dx,1,yw_wz+1)+Substr(dx,yw_wz+4,Len(dx)-(yw_wz+3)) Endif If Right(dx,2)="零" Do Case Case Len(dx)>2 dx=Left(dx,Len(dx)-2)+'整' Case Len(dx)<3 dx="" Endcase Endif If FC='负' dx=FC+(Substr(dx,3,Len(dx)-2)) Endif Return(dx) ENDPROC用这个函数