阿拉伯数字转换成英文大写.pdf
《阿拉伯数字转换成英文大写.pdf》由会员分享,可在线阅读,更多相关《阿拉伯数字转换成英文大写.pdf(4页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、启动 Microsoft Excel。按 Alt+F11 启动 Visual Basic 编辑器。在“插入”菜单上,单击“模块” 。在模块表中键入下面的代码。Option ExplicitMain FunctionFunction SpellNumber(ByValMyNumber)Dim Dollars, Cents, TempDim DecimalPlace, CountReDimPlace(9) As StringPlace(2) = Thousand Place(3) = Million Place(4) = Billion Place(5) = Trillion String rep
2、resentation of amount.MyNumber = Trim(Str(MyNumber) Position of decimal place 0 if none.DecimalPlace = InStr(MyNumber, .) Convert cents and set MyNumber to dollar amount.If DecimalPlace 0 ThenCents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _00, 2)MyNumber = Trim(Left(MyNumber, DecimalPlace -
3、1)End IfCount = 1Do While MyNumber Temp = GetHundreds(Right(MyNumber, 3)If Temp Then Dollars = Temp &Place(Count) & DollarsIf Len(MyNumber) 3 ThenMyNumber = Left(MyNumber, Len(MyNumber) - 3)ElseMyNumber = End IfCount = Count + 1LoopSelect Case DollarsCase Dollars = No DollarsCase OneDollars = One Do
4、llarCase ElseDollars = Dollars & DollarsEnd SelectSelect Case CentsCase Cents = and No CentsCase OneCents = and One CentCase ElseCents = and & Cents & CentsEnd SelectSpellNumber = Dollars & CentsEnd Function Converts a number from 100-999 into textFunction GetHundreds(ByValMyNumber)Dim Result As Str
5、ingIf Val(MyNumber) = 0 Then Exit FunctionMyNumber = Right(000 &MyNumber, 3) Convert the hundreds place.If Mid(MyNumber, 1, 1) 0 ThenResult = GetDigit(Mid(MyNumber, 1, 1) & Hundred End If Convert the tens and ones place.If Mid(MyNumber, 2, 1) 0 ThenResult = Result &GetTens(Mid(MyNumber, 2)ElseResult
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 阿拉伯数字 转换 英文 大写
限制150内