阿拉伯数字转大写数字的代码实例
时 间:2021-01-19 22:13:41
作 者:强联财务室 ID:77261 城市:北京
摘 要:阿拉伯数字转大写数字。
正 文:
学了点vba基础,动手练习敲代码,完成了阿拉伯数字向大写数字的功能,分享源代码如下:
----------------------------------------------------------------
Public Function Numtostr(Getnum) As String
Dim Num, z, x, c
Dim n, m, i, Point As Integer
Dim Str As String
Num = Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖")
z = Array("", "拾", "佰", "仟")
x = Array("", "万", "亿", "万亿")
c = Array("", "角", "分")
If InStr(Getnum, ".") = 0 Then
n = Len(Getnum)
For i = 1 To n
m = Mid(Getnum, i, 1)
Str = Str + Num(m)
If m > 0 Then Str = Str + z((n - i) Mod 4)
Str = Replace(Str, Num(0) & Num(0), Num(0))
If ((n - i) Mod 4) = 0 And Right(Str, 1) = Num(0) Then Str = Left(Str, Len(Str) - 1)
If ((n - i) Mod 4) = 0 Then Str = Str + x(Int((n - i) / 4))
Next i
Str = Str & "元整"
Else
Point = InStr(Getnum, ".") - 1
Getnum = Replace(Getnum, ".", "")
For i = 1 To Point
m = Mid(Getnum, i, 1)
Str = Str + Num(m)
If m > 0 Then Str = Str + z((Point - i) Mod 4)
Str = Replace(Str, Num(0) & Num(0), Num(0))
If ((Point - i) Mod 4) = 0 And Right(Str, 1) = Num(0) Then Str = Left(Str, Len(Str) - 1)
If ((Point - i) Mod 4) = 0 Then Str = Str + x(Int((Point - i) / 4))
Next i
Str = Str & "元"
For i = 1 To Len(Getnum) - Point
Str = Str + Num(Mid(Getnum, i + Point, 1))
If Num(Mid(Getnum, i + Point, 1)) = Num(0) Then
Str = Left(Str, Len(Str) - 1)
Else
Str = Str + c(i)
End If
Next i
End If
Numtostr = Str
End Function
可以在立即窗口中输入?Numtostr(1000100)看下结果。
Access软件网QQ交流群 (群号:54525238) Access源码网店
常见问答:
技术分类:
源码示例
- 【源码QQ群号19834647...(12.17)
- 统计当月之前(不含当月)的记录...(03.11)
- 【Access Inputbo...(03.03)
- 按回车键后光标移动到下一条记录...(02.12)
- 【Access Dsum示例】...(02.07)
- Access对子窗体的数据进行...(02.05)
- 【Access高效办公】上月累...(01.09)
- 【Access高效办公】上月累...(01.06)
- 【Access Inputbo...(12.23)
- 【Access Dsum示例】...(12.16)

学习心得
最新文章
- 【Access高效办公】如何让vb...(04.11)
- 仓库管理实战课程(10)-入库功能...(04.08)
- Access快速开发平台--Fun...(04.07)
- 仓库管理实战课程(9)-开发往来单...(04.02)
- 仓库管理实战课程(8)-商品信息功...(04.01)
- 仓库管理实战课程(7)-链接表(03.31)
- 仓库管理实战课程(6)-创建查询(03.29)
- 仓库管理实战课程(5)-字段属性(03.27)
- 设备装配出入库管理系统;基于Acc...(03.24)
- 仓库管理实战课程(4)-建表操作(03.22)