设为首页
|
收藏本站
|
繁体中文
|
手机版
整站搜索
资讯
技巧
源码
行业
设备(待改)
资源
信息库(待改)
产品
作品(待改)
活动
培训(视频)
平台(待改)
二级(待改)
互动(作废)
交易
Access培训
-
Access开发平台
-
Access行业开发
首页
资讯
技巧
源码
行业
资源
活动
关于
源码
ACCESS数据库
数据表
查询
界面/窗体/控件
报表打印
模块/函数/VBA/API/系统
网络通信游戏
API/COM/系统相关
加密解密安全
文件处理
经典算法
内置函数/模块
宏/菜单/工具栏/功能区
图表/图形/图像/多媒体
DAO/链接表/ADO/ADP
ActiveX/第三方控件/插件
OFFICE集成/导入导出/交互
SqlServer/其它数据库
Access完整系统
Access完整系统源码
Access软件作品(无源码)
杂项/其它
Excel源码
热门下载
access应用程序界面设..
动画启动窗体
Access完整日期时间的..
Access用VBA完全实..
系统外壳
access隐藏显示窗体中..
最新下载
Access登录窗体的做法..
多条件筛选记录(模糊搜索)
【Access小品】数据表..
【Access小品】后台管..
新增记录时复制过往指定记录..
access数据表视图和窗..
联系方式
Access交流网(免费Access交流)
QQ:18449932
网 址:
www.access-cn.com
当前位置:
首页
>
源码
>
界面/窗体/控件
界面/窗体/控件
access数字转英文大写示例源码
更新时间
2014-02-08 17:10:32
文件下载
点击下载
文件类型
文件版本
简要说明
详细描述
阿拉伯数字转英文,数字转中文数字,中文数字转大写数字。这些我们转换我们会经常用到。特别是会计财务行业。
下面的示例是一个自定义函数,数字(整数)转英文大写:数量转为英文数量,金额转为英文金额。
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
Place(5) = " Trillion "
' String representation 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 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count = 1
Do While MyNumber <> ""
Temp = GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "No Amount "
Case "One"
Dollars = "One"
Case Else
Dollars = Dollars
End Select
Select Case Cents
Case ""
Cents = " and No Cents"
Case "One"
Cents = " and One Cent"
Case Else
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Dollars & Cents
End Function</P>
<P>' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function</P>
<P>' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
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 Else
End Select
Result = Result & GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function</P>
<P>' Converts a number from 1 to 9 into text.
Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
数字转英文自定义函数
http://www.office-cn.net/forum.php?mod=viewthread&tid=33428
发布人:宿命的风-office中国
分享到:
点击次数:
更新时间:2014-02-08 17:10:32 【
打印此页
】 【
关闭
】
上一条:
access设置可选择的输入对话框
下一条:
access批量导入CSV文件
相关下载
•
【Access小品】数据表子窗体列宽锁定
•
【Access小品】后台管理二三事
•
新增记录时复制过往指定记录的示例
•
access数据表视图和窗体视图的互相切换
•
Access仿word查找功能--查找文本框中的字符
•
access复选框多选并显示
•
access连续窗体不同行显示不同颜色
•
【Access小品】希腊神话 -- 滚动窗体记录示例
热门下载
[2002-03-06]
自动调整栏宽及锁定栏宽
[2005-08-17]
非常方便通用且功能强大的Access查找窗体
[2002-02-27]
批量压缩和修复数据库的源码
[2013-08-21]
access 实现列表框多选操作
[2002-03-20]
gnoy做的复制选定记录的例子
[2015-12-11]
Access两个子窗体的数据关联(子窗体数据间的自动更新)
热门产品