转换
如何将数字转换成中文大写 如: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用这个函数
******************************* *程序名称: ZBSTRJE.PRG *功 能: 大写金额转换模块 *编 制: esailor(1999.12.31) ******************************* PARAMETERS TMP_N PRIVATE ALL LIKE TMP_* IF TMP_N=0 RETURN "零元整" ENDIF TMP_S1=IIF(TMP_N>0,"","(负)") TMP_N=IIF(TMP_N>0,TMP_N,-TMP_N) IF TMP_N>1000000000000 RETURN "超过"+TMP_S1+"壹万亿元" ENDIF TMP_STDT="仟佰拾亿仟佰拾万仟佰拾元角分" TMP_STDC="零壹贰叁肆伍陆柒捌玖" TMP_S0=STR(TMP_N*100,14) TMP_I0=14-LEN(LTRIM(TMP_S0))+1 FOR TMP_I=TMP_I0 TO 14 TMP_BIT=VAL(SUBSTR(TMP_S0,TMP_I,1)) TMP_T=SUBSTR(TMP_STDT,TMP_I*2-1,2) IF TMP_BIT=0 TMP_S1=IIF(RIGHT(TMP_S1,2)="零",TMP_S1,TMP_S1+"零") IF TMP_I=4 .OR. TMP_I=12 .OR.(TMP_I=8 .AND. .NOT.RIGHT(TMP_S1,4)="亿零") IF RIGHT(TMP_S1,2)="零" TMP_S1=SUBSTR(TMP_S1,1,LEN(TMP_S1)-2) TMP_S1=TMP_S1+TMP_T TMP_S1=TMP_S1+"零" ELSE TMP_S1=TMP_S1+TMP_T ENDIF ENDIF ELSE TMP_S1=TMP_S1+SUBSTR(TMP_STDC,TMP_BIT*2+1,2)+TMP_T ENDIF ENDFOR IF .NOT.RIGHT(TMP_S1,2)="分" IF RIGHT(TMP_S1,2)='零' TMP_S1=LEFT(TMP_S1,LEN(TMP_S1)-2) ENDIF TMP_S1=TMP_S1+'整' ENDIF RETURN TMP_S1