excel中数字转换英文大写程序_百度文库_第1页
excel中数字转换英文大写程序_百度文库_第2页
excel中数字转换英文大写程序_百度文库_第3页
excel中数字转换英文大写程序_百度文库_第4页
excel中数字转换英文大写程序_百度文库_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Function NumbToEnglish(ByVal MyNumberDim TempDim Inte, DecDim DecimalPlace, CountReDim Place(9 As StringPlace(2 = " Thousand "Place(3 = " Million "Place(4 = " Billion "Place(5 = " Trillion "' 将数字Mynumber 转换成字符串格式,并去掉多余空格MyNumber = Trim(Str(MyNumber' 查找

2、小数点“.”位置DecimalPlace = InStr(MyNumber, "."' 如果找到小数点.If DecimalPlace > 0 Then' 转换小数部分Temp = Len(Mid(MyNumber, DecimalPlace + 1Count = 1Dec = ""Do While Count - 1 <> TempDec = Dec & " " & ConvertDecimal(Mid(MyNumber,DecimalPlace + Count, 1Count =

3、Count + 1Loop' 去掉小数部分,保留剩下的整数部分留做转换MyNumber = Trim(Left(MyNumber, DecimalPlace - 1 End IfCount = 1Do While MyNumber <> ""' 将最后的三位数字转换成英文数字Temp = ConvertHundreds(Right(MyNumber, 3If Temp <> "" Then Inte = Temp & Place(Count & Inte If Len(MyNumber > 3

4、 Then' 如果整数部分大于三位,再向前移动三位数字重复进行转换 MyNumber = Left(MyNumber, Len(MyNumber - 3ElseMyNumber = ""End IfCount = Count + 1Loop' 增加小数点描述If Dec = "" ThenIf Inte = "" ThenDec = "No Number!"End IfElseIf Inte = "" ThenDec = "Zero Point" &

5、DecElseDec = " Point" & DecEnd IfEnd IfNumbToEnglish = Inte & DecEnd Function' 定义子函数,转换百位数Private Function ConvertHundreds(ByVal MyNumberDim Result As String' 如果数字为空,退出.If Val(MyNumber = 0 Then Exit Function' 在不满三位数的数字前补"0".MyNumber = Right("000" &am

6、p; MyNumber, 3' 判断是否有百位数可供转换?If Left(MyNumber, 1 <> "0" ThenIf Right("000" & MyNumber, 2 <> 0 ThenResult = ConvertDigit(Left(MyNumber, 1 & " Hundred and " ElseResult = ConvertDigit(Left(MyNumber, 1 & " Hundred " End IfEnd If' 判断

7、是否有十位数可供转换?If Mid(MyNumber, 2, 1 <> "0" ThenResult = Result & ConvertTens(Mid(MyNumber, 2Else' 如果没有,转换个位数.Result = Result & ConvertDigit(Mid(MyNumber, 3End IfConvertHundreds = Trim(ResultEnd Function' 定义子函数,转换十位数Private Function ConvertTens(ByVal MyTensDim Result As S

8、tring' 判断数字是否在 10 - 19 之间?If Val(Left(MyTens, 1 = 1 ThenSelect Case Val(MyTensCase 10: Result = "Ten"Case 11: Result = "Eleven"Case 12: Result = "Twelve"Case 13: Result = "Thirteen"Case 14: Result = "Fourteen"Case 15: Result = "Fifteen"

9、Case 16: Result = "Sixteen"Case 17: Result = "Seventeen"Case 18: Result = "Eighteen"Case 19: Result = "Nineteen"Case ElseEnd SelectElse' . 否则, 它是介于 20 - 99 之间.Select Case Val(Left(MyTens, 1Case 2: Result = "Twenty"Case 3: Result = "Thirty&qu

10、ot;Case 4: Result = "Forty"Case 5: Result = "Fifty"Case 6: Result = "Sixty"Case 7: Result = "Seventy"Case 8: Result = "Eighty"Case 9: Result = "Ninety"Case ElseEnd Select' 转换其中的个位数.If Val(Right(MyTens, 1 = 0 ThenResult = Result & &q

11、uot; " & ConvertDigit(Right(MyTens, 1 ElseResult = Result & "-" & ConvertDigit(Right(MyTens, 1 End IfEnd IfConvertTens = ResultEnd Function' 定义子函数,转换个位数Private Function ConvertDigit(ByVal MyDigitSelect Case Val(MyDigitCase 1: ConvertDigit = "One"Case 2: Conve

12、rtDigit = "Two"Case 3: ConvertDigit = "Three"Case 4: ConvertDigit = "Four"Case 5: ConvertDigit = "Five"Case 6: ConvertDigit = "Six"Case 7: ConvertDigit = "Seven"Case 8: ConvertDigit = "Eight"Case 9: ConvertDigit = "Nine"

13、Case Else: ConvertDigit = ""End SelectEnd Function' 定义子函数,转换小数部分Private Function ConvertDecimal(ByVal MyDecimalSelect Case Val(MyDecimalCase 1: ConvertDecimal = "One"Case 2: ConvertDecimal = "Two"Case 3: ConvertDecimal = "Three"Case 4: ConvertDecimal = "Four"Case 5: ConvertDecimal = "Five"Case 6: ConvertDecimal = "Six"Case 7: ConvertDecimal = "Seven"Case 8: ConvertDecimal = "Eight"Case 9:

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论