软件开发的家园,编程爱好者的天地.

rss  设为首页  |  加入收藏  |   网站地图

当前位置: 主页 > Asp.Net >

数字转英文(货币)大写
发布于:软件开发网 来源:互联网 作者:佚名 时间:2009-02-24 点击:


'功能模块:数字转英文(货币)大写
'PublicFunctionNumberToString(NumberAsDouble)AsString
'调用形式:debug.printNumberToString(1234.32)
'说明:最大支持12位数字,小数点后精确两位
'程序:杨鑫光(Volitation)
DimStrNO(19)AsString
DimUnit(8)AsString
DimStrTens(9)AsString

软件开发网

PublicFunctionNumberToString(NumberAsDouble)AsString
DimStrAsString,BeforePointAsString,AftERPointAsString,tmpStrAsString
DimPointAsInteger
DimnBitAsInteger
DimCurStringAsString
CallInit
'//开始处理
Str=CStr(Round(Number,2))
'Str=Number
IfInStr(1,Str,".")=0Then
BeforePoint=Str
AfterPoint=""
Else
BeforePoint=Left(Str,InStr(1,Str,".")-1)
AfterPoint=Right(Str,Len(Str)-InStr(1,Str,"."))
EndIf

IfLen(BeforePoint)>12Then
NumberToString="TooBig."
ExitFunction
EndIf
Str=""
DoWhileLen(BeforePoint)>0
nNUMLen=Len(BeforePoint)
IfnNumLenMod3=0Then
CurString=Left(BeforePoint,3)
BeforePoint=Right(BeforePoint,nNumLen-3)
Else
CurString=Left(BeforePoint,(nNumLenMod3))
BeforePoint=Right(BeforePoint,nNumLen-(nNumLenMod3))
EndIf
nBit=Len(BeforePoint)/3
tmpStr=DecodeHundred(CurString)

http://www.mscto.com

If(BeforePoint=String(Len(BeforePoint),"0")OrnBit=0)AndLen(CurString)=3Then
IfCInt(Left(CurString,1))<>0AndCInt(Right(CurString,2))<>0Then
tmpStr=Left(tmpStr,InStr(1,tmpStr,Unit(4)) Len(Unit(4)))&Unit(8)&""&Right(tmpStr,Len(tmpStr)-(InStr(1,tmpStr,Unit(4)) Len(Unit(4))))
Else'IfCInt(Left(CurString,1))<>0AndCInt(Right(CurString,2))=0Then
tmpStr=Unit(8)&""&tmpStr
EndIf
EndIf

IfnBit=0Then
Str=Trim(Str&""&tmpStr)
Else
Str=Trim(Str&""&tmpStr&""&Unit(nBit))
EndIf
IfLeft(Str,3)=Unit(8)ThenStr=Trim(Right(Str,Len(Str)-3))
IfBeforePoint=String(Len(BeforePoint),"0")ThenExitDo
'Debug.PrintStr
Loop
BeforePoint=Str

IfLen(AfterPoint)>0Then
AfterPoint=Unit(6)&""&DecodeHundred(AfterPoint)&""&Unit(7)
Else
AfterPoint=Unit(5)

http://www.mscto.com


EndIf
NumberToString=BeforePoint&""&AfterPoint
EndFunction
PrivateFunctionDecodeHundred(HundredStringAsString)AsString
DimtmpAsInteger
IfLen(HundredString)>0AndLen(HundredString)<=3Then
SelectCaseLen(HundredString)
Case1
tmp=CInt(HundredString)
Iftmp<>0ThenDecodeHundred=StrNO(tmp)
Case2
tmp=CInt(HundredString)
Iftmp<>0Then
If(tmp<20)Then
DecodeHundred=StrNO(tmp)
Else
IfCInt(Right(HundredString,1))=0Then
DecodeHundred=StrTens(Int(tmp/10))



本文关键词:

上一篇:VSTS Team System 总算装好了。
下一篇:具有自动完成功能的ComboBox

对我有帮助
(0)
0%
对我没帮助
(0)
0%

网友评论


以下留言只代表网友个人观点,不代表本站观点.