数字转换为大写(vfp)

类别:数据库 点击:0 评论:0 推荐:

PARAMETERS lnMoney
lnNumber = lnMoney
ChinaMoney = ""
DIME ChinaNo(10)
ChinaNo(1) = "零"
ChinaNo(2) = "壹"
ChinaNo(3) = "贰"
ChinaNo(4) = "叁"
ChinaNo(5) = "肆"
ChinaNo(6) = "伍"
ChinaNo(7) = "陆"
ChinaNo(8) = "柒"
ChinaNo(9) = "捌"
ChinaNo(10) = "玖"
DIME Cdw(2)
Cdw(1)="角"
Cdw(2)="分"
DIME ChinaNum(10)
ChinaNum(1) = "元"
ChinaNum(2) = "拾"
ChinaNum(3) = "佰"
ChinaNum(4) = "仟"
ChinaNum(5) = "万"
ChinaNum(6) = "拾"
ChinaNum(7) = "佰"
ChinaNum(8) = "仟"
ChinaNum(9) = "亿"
ChinaNum(10) = "拾"
lnIntNumber = INT(lnNumber)
lcIntNumber = ALLTRIM(STR(lnIntNumber,10,0))
lnDicNumber = Int((lnNumber-lnIntNumber)*100)
lcDicNumber = IIF(!EMPTY(lnDicNumber),STR(lnDicNumber,2,0),"")

N = 1
FOR I = LEN(lcIntNumber) TO 1 STEP -1
 FOR J = 1 TO 10
  IF VAL(SUBST(lcIntNumber,I,1)) = J-1
   ChinaMoney = ChinaNo(J)+ChinaNum(N)+ChinaMoney
   N = N+1
   EXIT
  ENDIF
 ENDFOR
ENDFOR
IF !EMPTY(lcDicNumber)
 FOR Z = 1 TO 2
  FOR P = 1 TO 10
   IF VAL(SUBST(lcDicNumber,Z,1)) = P-1
    ChinaMoney = ChinaMoney+ChinaNo(P)+Cdw(Z)
    EXIT
   ENDIF
  ENDFOR
 ENDFOR
ELSE
 ChinaMoney=ChinaMoney+"整"
ENDIF
RETURN ChinaMoney

本文地址:http://com.8s8s.com/it/it21525.htm