数字转换为大写(vfp)

发表于:2007-05-25来源:作者:点击数: 标签:PARAMETERS大写VFP数字转换
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) = "捌" ChinaN

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://www.ltesting.net