如要打印一个现金发票程序,如用户去移动公司交话费打印话费发票,会显示数据通信费xx元等。
最后一个总合计xx元,并用大写显示出来。
该怎么编呢?
谢啦!
请参考下面函数: *: 以下为小写金额转换成大写金额的实现 *:************************************** *:函 数 名:XX2DX *:功 能:小写金额转换成大写金额 *:入口参数:小写金额 *:出口参数:大写金额 *:************************************** FUNCTION XX2DX PARAMETERS tnXXNumber PRIVATE pcJEStr, pcDXNumber, pnPointPos, pcPointStr, pcCnNum, pcCnDW PRIVATE pnTmpI, pnTmpJ, pnTmpValue, pnTmpValu2, pnHaveZero
pcDXNumber = '' IF NOT TYPE('tnXXNumber') == 'N' RETURN '非法的参数类型' ENDIF IF tnXXNumber = 0 RETURN '零元整' ENDIF IF tnXXNumber < 0 tnXXNumber = ABS(tnXXNumber) pcDXNumber = '(负)' ENDIF
pcCnNum = '零壹贰叁肆伍陆柒捌玖' pcCnDW = '仟佰拾亿仟佰拾万仟佰拾元' && 最大转换长度12位 pnHaveZero = 0 pcJEStr = ALLTRIM(STR(tnXXNumber, 15, 2)) pnPointPos = AT('.', pcJEStr) IF pnPointPos <> 0 pcPointStr = SUBSTR(pcJEStr, pnPointPos + 1) pcJEStr = LEFT(pcJEStr, pnPointPos - 1) IF VAL(pcPointStr) = 0 pnPointPos = 0 pcPointStr = '' ENDIF ENDIF IF tnXXNumber >= 1.00 pnTmpJ = 13 - LEN(pcJEStr) pnTmpI = 1 DO WHILE pnTmpJ <= 12 pnTmpValue = VAL(SUBSTR(pcJEStr,pnTmpI,1)) IF pnTmpValue <> 0 IF pnHaveZero <> 0 pcDXNumber = pcDXNumber + '零' pnHaveZero = 0 ENDIF pcDXNumber = pcDXNumber + SUBSTR(pcCnNum, 2 * pnTmpValue + 1, 2); + SUBSTR(pcCnDW, 2*pnTmpJ - 1, 2) ELSE pnHaveZero = pnHaveZero + 1 IF pnTmpJ % 4 = 0 AND pnHaveZero < 4 pcDXNumber = pcDXNumber + SUBSTR(pcCnDW, 2 * pnTmpJ - 1, 2) ENDIF ENDIF pnTmpJ = pnTmpJ + 1 pnTmpI = pnTmpI + 1 ENDDO ENDIF
IF EMPTY(pcDXNumber) pcDXNumber = pcDXNumber + '零' ENDIF IF NOT RIGHT(pcDXNumber, 2) == '元' pcDXNumber = pcDXNumber + '元' ENDIF
IF pnPointPos = 0 pcDXNumber = pcDXNumber + '整' ELSE pnTmpValu2 = 0 pnTmpValue = VAL(LEFT(pcPointStr, 1)) IF pnTmpValue <> 0 pcDXNumber = pcDXNumber + SUBSTR(pcCnNum, 2 * pnTmpValue + 1, 2) + '角' ENDIF IF LEN(pcPointStr) > 1 pnTmpValu2 = VAL(RIGHT(pcPointStr, 1)) DO CASE CASE pnTmpValu2 <> 0 AND pnTmpValue = 0 pcDXNumber = pcDXNumber + '零' + ; SUBSTR(pcCnNum, 2 * pnTmpValu2 + 1, 2) ; + '分' CASE pnTmpValu2 <> 0 AND pnTmpValue <> 0 pcDXNumber = pcDXNumber + ; SUBSTR(pcCnNum, 2 * pnTmpValu2 + 1, 2) ; + '分' ENDCASE ENDIF ENDIF
IF RIGHT(pcDXNumber,2) == '角' * 末位是角则加整 pcDXNumber = pcDXNumber + '整' ENDIF RETURN pcDXNumber