调用方法Text2=ChMoney(Val(Text1))
名称:CCh
得到一位数字N1的汉字大写
0返回””
PrivateFunctionCCh(N1)AsString
SelectCaseN1
Case0
CCh=”零”
Case1
CCh=”壹”
Case2
CCh=”贰”
Case3
CCh=”叁”
Case4
CCh=”肆”
Case5
CCh=”伍”
Case6
CCh=”陆”
Case7
CCh=”柒”
Case8
CCh=”捌”
Case9
CCh=”玖”
EndSelect
EndFunction
名称:ChMoney
得到数字N1的汉字大写
最大为千万位
O返回””
PublicFunctionChMoney(N1)AsString
DimtMoneyAsString
DimlMoneyAsString
Dimtn小数位置
Dims1AsString临时STRING小数部分
Dims2AsString1000以内
Dims3AsString10000
IfN1=0Then
ChMoney=””
ExitFunction
EndIf
IfN1<0Then
ChMoney=”负” ChMoney(Abs(N1))
ExitFunction
EndIf
tMoney=Trim(Str(N1))
tn=InStr(tMoney,”.”)小数位置
s1=””
Iftn<>0Then
ST1=Right(tMoney,Len(tMoney)-tn)
IfST1<>””Then
t1=Left(ST1,1)
ST1=Right(ST1,Len(ST1)-1)
Ift1<>”0″Then
s1=s1 CCh(Val(t1)) “角”
EndIf
IfST1<>””Then
t1=Left(ST1,1)
s1=s1 CCh(Val(t1)) “分”
EndIf
EndIf
ST1=Left(tMoney,tn-1)
Else
ST1=tMoney
EndIf
s2=””
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
s2=CCh(Val(t1)) s2
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s2=CCh(Val(t1)) “拾” s2
Else
IfLeft(s2,1)<>”零”Thens2=”零” s2
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s2=CCh(Val(t1)) “佰” s2
Else
IfLeft(s2,1)<>”零”Thens2=”零” s2
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s2=CCh(Val(t1)) “仟” s2
Else
IfLeft(s2,1)<>”零”Thens2=”零” s2
EndIf
EndIf
s3=””
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
s3=CCh(Val(t1)) s3
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s3=CCh(Val(t1)) “拾” s3
Else
IfLeft(s3,1)<>”零”Thens3=”零” s3
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s3=CCh(Val(t1)) “佰” s3
Else
IfLeft(s3,1)<>”零”Thens3=”零” s3
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s3=CCh(Val(t1)) “仟” s3
EndIf
EndIf
IfRight(s2,1)=”零”Thens2=Left(s2,Len(s2)-1)
IfLen(s3)>0Then
IfRight(s3,1)=”零”Thens3=Left(s3,Len(s3)-1)
s3=s3&”万”
EndIf
ChMoney=IIf(s3&s2=””,s1,s3&s2&”元”&s1)
EndFunction
调用方法Text2=ChMoney(Val(Text1))
名称:CCh
得到一位数字N1的汉字大写
0返回””
PrivateFunctionCCh(N1)AsString
SelectCaseN1
Case0
CCh=”零”
Case1
CCh=”壹”
Case2
CCh=”贰”
Case3
CCh=”叁”
Case4
CCh=”肆”
Case5
CCh=”伍”
Case6
CCh=”陆”
Case7
CCh=”柒”
Case8
CCh=”捌”
Case9
CCh=”玖”
EndSelect
EndFunction
名称:ChMoney
得到数字N1的汉字大写
最大为千万位
O返回””
PublicFunctionChMoney(N1)AsString
DimtMoneyAsString
DimlMoneyAsString
Dimtn小数位置
Dims1AsString临时STRING小数部分
Dims2AsString1000以内
Dims3AsString10000
IfN1=0Then
ChMoney=””
ExitFunction
EndIf
IfN1<0Then
ChMoney=”负” ChMoney(Abs(N1))
ExitFunction
EndIf
tMoney=Trim(Str(N1))
tn=InStr(tMoney,”.”)小数位置
s1=””
Iftn<>0Then
ST1=Right(tMoney,Len(tMoney)-tn)
IfST1<>””Then
t1=Left(ST1,1)
ST1=Right(ST1,Len(ST1)-1)
Ift1<>”0″Then
s1=s1 CCh(Val(t1)) “角”
EndIf
IfST1<>””Then
t1=Left(ST1,1)
s1=s1 CCh(Val(t1)) “分”
EndIf
EndIf
ST1=Left(tMoney,tn-1)
Else
ST1=tMoney
EndIf
s2=””
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
s2=CCh(Val(t1)) s2
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s2=CCh(Val(t1)) “拾” s2
Else
IfLeft(s2,1)<>”零”Thens2=”零” s2
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s2=CCh(Val(t1)) “佰” s2
Else
IfLeft(s2,1)<>”零”Thens2=”零” s2
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s2=CCh(Val(t1)) “仟” s2
Else
IfLeft(s2,1)<>”零”Thens2=”零” s2
EndIf
EndIf
s3=””
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
s3=CCh(Val(t1)) s3
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s3=CCh(Val(t1)) “拾” s3
Else
IfLeft(s3,1)<>”零”Thens3=”零” s3
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s3=CCh(Val(t1)) “佰” s3
Else
IfLeft(s3,1)<>”零”Thens3=”零” s3
EndIf
EndIf
IfST1<>””Then
t1=Right(ST1,1)
ST1=Left(ST1,Len(ST1)-1)
Ift1<>”0″Then
s3=CCh(Val(t1)) “仟” s3
EndIf
EndIf
IfRight(s2,1)=”零”Thens2=Left(s2,Len(s2)-1)
IfLen(s3)>0Then
IfRight(s3,1)=”零”Thens3=Left(s3,Len(s3)-1)
s3=s3&”万”
EndIf
ChMoney=IIf(s3&s2=””,s1,s3&s2&”元”&s1)
EndFunction->