测试版主的函数,出现乱码,如果是我程序打错,请指出。
?ConvertCurrencyToChinese(100)
RETURN
*--------------
FUNCTION ConvertCurrencyToChinese(tnCurrency)
LOCAL lcTemplate, lcCurrency
LOCAL lcString, lnIndex, lnStart
LOCAL lcBuffer, lnPos1, lnPos2
IF (VARTYPE(tnCurrency) !='N') .OR. EMPTY(tnCurrency)
RETURN ""
ENDIF
lcTemplate = "仟佰拾亿仟佰拾万仟佰拾元角分"
lcCurrency = "零壹贰叁肆伍陆柒捌玖"
lcBuffer = TRANSFORM(ROUND(tnCurrency,2))
IF AT(".",lcBuffer)==0
lcBuffer =lcBuffer+".00"
ENDIF
lcBuffer =STUFF(lcBuffer,AT('.',lcBuffer),1,"")
lcString=""
lnStart=IIF(RIGHT(lcBuffer,2)!="00",LEN(lcBuffer),LEN(lcBuffer)-2)
FOR lnIndex=lnStart TO 1 STEP -1
lnPos1=ASC(SUBSTR(lcBuffer,lnIndex,1))-ASC('0')+1
lnPos2=LENC(lcTemplate)-LEN(lcBuffer)+lnIndex
lcString =SUBSTR(lcCurrency,lnPos1,1)+SUBSTRC(lcTemplate,lnPos2,1)+lcString
NEXT
RETURN lcString
ENDFUNC
?ConvertCurrencyToChinese(100)
RETURN
*--------------
FUNCTION ConvertCurrencyToChinese(tnCurrency)
LOCAL lcTemplate, lcCurrency
LOCAL lcString, lnIndex, lnStart
LOCAL lcBuffer, lnPos1, lnPos2
IF (VARTYPE(tnCurrency) !='N') .OR. EMPTY(tnCurrency)
RETURN ""
ENDIF
lcTemplate = "仟佰拾亿仟佰拾万仟佰拾元角分"
lcCurrency = "零壹贰叁肆伍陆柒捌玖"
lcBuffer = TRANSFORM(ROUND(tnCurrency,2))
IF AT(".",lcBuffer)==0
lcBuffer =lcBuffer+".00"
ENDIF
lcBuffer =STUFF(lcBuffer,AT('.',lcBuffer),1,"")
lcString=""
lnStart=IIF(RIGHT(lcBuffer,2)!="00",LEN(lcBuffer),LEN(lcBuffer)-2)
FOR lnIndex=lnStart TO 1 STEP -1
lnPos1=ASC(SUBSTR(lcBuffer,lnIndex,1))-ASC('0')+1
lnPos2=LENC(lcTemplate)-LEN(lcBuffer)+lnIndex
lcString =SUBSTR(lcCurrency,lnPos1,1)+SUBSTRC(lcTemplate,lnPos2,1)+lcString
NEXT
RETURN lcString
ENDFUNC