把數字轉換為大寫

FUNC CHNUM
PARA nAmount
PRIV ALL LIKE L_*
L_S1=”零壹貳三肆伍陸柒捌玖”
L_S2=”億仟佰拾萬仟佰拾億仟佰拾萬仟佰拾元角分”

nAmount=LTRI(STR(nAmount*100,LEN(L_S2)/2))
L_LEN=LEN(nAmount)
L_SS2=RIGH(L_S2,2*L_LEN)
L_DX=”"
L_0JS=0
FOR L_N=1 TO L_LEN
L_SZ=SUBS(nAmount,L_N,1)
L_SZ=SUBS(L_S1,2*VAL(L_SZ)+1,2)
L_DW=SUBS(L_SS2,2*L_N-1,2)
IF L_SZ=”零”
L_SZ=”"
DO CASE
CASE L_DW$”億元”
CASE L_DW=”萬”
IF RIGH(L_DX,2)=”億”
L_DW=”"
ENDI
OTHE
L_DW=”"
ENDC
L_0JS=L_0JS+1
ELSE
IF L_0JS>0.AND.!(RIGH(L_DX,2)+L_DW)$L_SS2
L_SZ=”零”+L_SZ
ENDI
L_0JS=0
ENDI
L_DX=L_DX+L_SZ+L_DW
ENDF
L_DX=L_DX+IIF(RIGH(nAmount,1)=”0″,”整”,”")
RETU L_DX

posted @ 2008-10-03 13:43  月亮不合眼  阅读(402)  评论(0编辑  收藏  举报