请教各位仁兄:关于VFP的小问题(100分)

  • 主题发起人 主题发起人 webb
  • 开始时间 开始时间
W

webb

Unregistered / Unconfirmed
GUEST, unregistred user!
在vfp中,如何将小写金额转换为人民币大写形式?
 
自已写个函数不就行了
 
我有一函数,VFP的,要不?
 
用函数实现,思想都是一样的,只是用的语言不同而已。
 
http://klz.myrice.com/program/vfp/008.htm把数字金额转换为大写金额

*/!********************************************************
*/! Function Name: CaseMoney
*/! Description: 把数字金额转为人民币大写格式
*/! Usage: =caseMoney(金额) 金额是数字型
*/!********************************************************
Function CaseMoney
PARA Money
*辨别是否是数字金额
IF TYPE("Money") #"N"
=messagebox(" 金额类型出错",0,_screen.caption)
Return " "
EndIF
*转换金额为字符型
IF Money>9999999999999.99
=messagebox(" 数值太大,无法处理",0,_screen.caption)
Return " "
EndIF
CMoney=Allt(Str(Money,16,2))
*定义数组
DIME CaseFormat(10)
CaseFormat(1) ="壹"
CaseFormat(2) ="贰"
CaseFormat(3) ="叁"
CaseFormat(4) ="肆"
CaseFormat(5) ="伍"
CaseFormat(6) ="陆"
CaseFormat(7) ="柒"
CaseFormat(8) ="捌"
CaseFormat(9) ="玖"
Dime Unit(3)
Unit(1) ="拾"
Unit(2) ="百"
Unit(3) ="千"
*开始转换
M_Cmoney=""
MoneyLen=len(CMoney)
J=0
For i=MoneyLen To 1 step -1
Nowmoney=val(substr(CMoney,i,1))
IF Nowmoney>0
do
case
Case i = MoneyLen
M_Cmoney=CaseFormat(Nowmoney)+"分"
Case i = MoneyLen-1
M_Cmoney="元"+CaseFormat(Nowmoney)+"角"+M_Cmoney
Case i = MoneyLen-3
M_Cmoney=CaseFormat(Nowmoney)+M_Cmoney
Case i < MoneyLen-3
IF mod((J+1),4)>0
M_Cmoney=CaseFormat(Nowmoney)+Unit(mod(J+1,4))+M_Cmoney
else
M_J = int((j+1)/4)-1
IF M_J>0
IF M_J = 1 or M_J = 3
M_C = "万"+m_C
else
M_C = "亿"+m_C
Endif
EndIF
IF left(M_Cmoney,2)="万"
M_Cmoney=right(M_Cmoney,len(M_Cmoney)-2)
EndIF
M_Cmoney=CaseFormat(Nowmoney)+M_C+M_Cmoney
EndIF
EndCase
else
do
case
Case i = MoneyLen-1
IF Empty(M_Cmoney)
M_Cmoney="元整"
else
M_Cmoney="元零"+M_Cmoney
EndIF
Case i < MoneyLen-3
IF mod((J+1),4)>0
IF substr(M_Cmoney,1,2)#"零" and !substr(M_Cmoney,1,2)$"万亿元"
M_Cmoney="零" +M_Cmoney
EndIF
else
M_J = int((j+1)/4)-1
IF M_J>0
IF M_J = 1 or M_J = 3
M_C = "万"+m_C
else
M_C = "亿"+m_C
Endif
EndIF
IF substr(M_Cmoney,1,2)="万"
M_Cmoney=right(M_Cmoney,len(M_Cmoney)-2)
EndIF
M_Cmoney=M_C+M_Cmoney
EndIF
EndCase
EndIf
j=j+1
EndFor
Return M_Cmoney
 
接受答案了.
 
后退
顶部