



下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1.阿拉伯数字转换中文大写。=IF(A7-INT(A7)=0,TEXT(A7,"DBNUM2")&"元整",IF(INT(A7*10)-A7*10=0,TEXT(INT(A7),"DBNUM2")&"元"&TEXT(INT(A7*10)-INT(A7)*10),"DBNUM2")&"角整",TEXT(INT(A7),"DBNUM2")&"元"&IF(INT(A7*10)-INT(A7)*1
2、0=0,"零",TEXT(INT(A7*10)-INT(A7)*10,"DBNUM2")&"角")&TEXT(RIGHT(A7,1),"DBNUM2")&"分")该函数中只需将A7换成你要转换的数值所在单元格即可。(编写SpellNumber实例函数)2.1 启动 Microsoft Excel。 2.2 按 Alt+F11 启动 Visual Basic 编辑器。 2.3 在“插入”菜单上,单击“模块”。 2.4 在模块表中键入下面的代码。Function Conver
3、tCurrencyToEnglish(ByVal MyNumber) Dim Temp Dim Dollars, Cents Dim DecimalPlace, Count
4、0; ReDim Place(9) As String Place(2) = " Thousand " Place(3) = " Million " Place(4) = " Billion "
5、; Place(5) = " Trillion " ' Convert MyNumber to a string, trimming extra spaces. MyNumber = Trim(Str(Round(MyNumber, 2)
6、; ' Find decimal place. DecimalPlace = InStr(MyNumber, ".") ' If we find decimal place.
7、60; If DecimalPlace > 0 Then ' Convert cents Temp = Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2)
8、 Cents = ConvertTens(Temp) ' Strip off cents from remainder to convert. MyNumber = Trim(Left(MyNumber, DecimalPlace
9、- 1) End If Count = 1 Do While MyNumber <> "" '
10、; Convert last 3 digits of MyNumber to English dollars. Temp = ConvertHundreds(Right(MyNumber, 3) If Temp <> "" Then Dollars = Temp & Pl
11、ace(Count) & Dollars If Len(MyNumber) > 3 Then ' Remove last 3 converted digits from MyNumber.
12、60; MyNumber = Left(MyNumber, Len(MyNumber) - 3) Else MyNumber = "" &
13、#160; End If Count = Count + 1 Loop ' Clean up dollars.&
14、#160; Select Case Dollars Case "" Dollars = "No Dollars"
15、160; Case "One" Dollars = "One Dollar" Case Else
16、0; Dollars = Dollars & " Dollars" End Select ' Clean up cents.
17、0; Select Case Cents Case "" Cents = " Only"
18、160; Case "One" Cents = " And One Cent" Case Else
19、60; Cents = " And " & Cents & " Cents" End Select ConvertCurrencyToEnglish = Dollars & Cents End Fun
20、ction Private Function ConvertHundreds(ByVal MyNumber) Dim Result As String ' Exit if there is nothing to convert.
21、160; If Val(MyNumber) = 0 Then Exit Function ' Append leading zeros to number. MyNumber = Right("000" & MyNumber, 3)
22、0; ' Do we have a hundreds place digit to convert? If Left(MyNumber, 1) <> "0" Then If Right("000" & MyNumber, 2) <> 0 Then
23、; Result = ConvertDigit(Left(MyNumber, 1) & " Hundred and " Else Result = ConvertD
24、igit(Left(MyNumber, 1) & " Hundred " End If End If ' Do we have a tens place digit to convert?
25、160; If Mid(MyNumber, 2, 1) <> "0" Then Result = Result & ConvertTens(Mid(MyNumber, 2) Else
26、60; ' If not, then convert the ones place digit. Result = Result & ConvertDigit(Mid(MyNumber, 3) End If
27、60; ConvertHundreds = Trim(Result) End Function Private Function ConvertTens(ByVal MyTens) Dim Result As String
28、60; ' Is value between 10 and 19? If Val(Left(MyTens, 1) = 1 Then Select Case Val(MyTens)
29、60; Case 10: Result = "Ten" Case 11: Result = "Eleven" Case 12: Result = &qu
30、ot;Twelve" Case 13: Result = "Thirteen" Case 14: Result = "Fourteen"
31、60; Case 15: Result = "Fifteen" Case 16: Result = "Sixteen"
32、; Case 17: Result = "Seventeen" Case 18: Result = "Eighteen" Case 19: Result = &qu
33、ot;Nineteen" Case Else End Select Else
34、; ' . otherwise it's between 20 and 99. Select Case Val(Left(MyTens, 1) Case 2: Result = "Twent
35、y" Case 3: Result = "Thirty" Case 4: Result = "Forty"
36、 Case 5: Result = "Fifty" Case 6: Result = "Sixty" C
37、ase 7: Result = "Seventy" Case 8: Result = "Eighty" Case 9: Result = "Ninety" &
38、#160; Case Else End Select ' Convert ones place digit.
39、160; If Val(Right(MyTens, 1) = 0 Then Result = Result & " " & ConvertDigit(Right(MyTens, 1) Else
40、 Result = Result & "-" & ConvertDigit(Right(MyTens, 1) End If End If ConvertTens = Result End Function Private Function ConvertDigit(ByVal MyDigit) Select Case Val(MyDigit) &
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高频开关直流电源柜项目投资可行性研究分析报告(2024-2030版)
- 2025年中国DLP光显屏行业市场调查研究及发展趋势预测报告
- 采掘知识培训课件
- 2025年中国柑桔行业市场全景评估及发展战略规划报告
- 2024-2030年中国云VR行业发展运行现状及投资潜力预测报告
- 2025年中国制糖行业发展运行现状及投资潜力预测报告
- 2025年中国蓝宝石长晶炉行业发展趋势预测及投资战略咨询报告
- 2025年 云南省化工仪表操作证理论考试练习题附答案
- 2025年 特种设备作业人员-叉车证理论考试练习题附答案
- 中国现调机行业市场全景分析及投资前景展望报告
- TCPSS 1011-2024 直流散热风扇运行寿命测试方法
- 2025年广西初中学业水平模拟测试(一)数学(原卷版+解析版)
- 人防门二次浇筑施工方案
- 湖南长沙四大名校系丘班选拔试题
- 病案管理法律法规课件
- 医学分子生物学习题集
- 2025年山东水发集团有限公司总部及权属一级公司招聘笔试参考题库附带答案详解
- 七年级数学下册 第二学期 期末测试卷(苏科版 2025年春)
- 高级私人马术俱乐部会员权益协议
- 政务服务窗口人员培训
- 2025年江苏南京河西新城区国有资产经营控股集团招聘笔试参考题库附带答案详解
评论
0/150
提交评论