设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1672|回复: 5
打印 上一主题 下一主题

[与其它组件] 如何将数字转换成英文的大写?

[复制链接]
跳转到指定楼层
1#
发表于 2003-10-11 17:52:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我是做货代的,在打印提单时经常要将数字转换成英文大写格式,每次都手动太麻烦了,请问有没有什么函数或者控件可是实现自动转换?谢谢啊
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2003-10-11 18:22:00 | 只看该作者
你搜索一下吧,好像論壇上有的,具體在哪,你要自已找找
我好像昨天還在accxp上看到,也有
3#
发表于 2003-10-11 18:33:00 | 只看该作者
數字轉英文(金額轉換)源碼
Public Function x(num As String) As String
Select Case num
Case "0": x = ""
Case "1": x = "one"
Case "2": x = "two"
Case "3": x = "three"
Case "4": x = "four"
Case "5": x = "five"
Case "6": x = "six"
Case "7": x = "seven"
Case "8": x = "eight"
Case "9": x = "nine"
End Select
End Function
Public Function xxa(num As String) As String
Select Case num
Case "2": xxa = "twenty"
Case "3": xxa = "thirty"
Case "4": xxa = "forty"
Case "5": xxa = "fifty"
Case "6": xxa = "sixty"
Case "7": xxa = "seventy"
Case "8": xxa = "eighty"
Case "9": xxa = "ninety"
End Select
End Function
Public Function xxb(num As String) As String
Select Case num
Case "10": xxb = "ten"
Case "11": xxb = "eleven"
Case "12": xxb = "twelve"
Case "13": xxb = "thirteen"
Case "14": xxb = "fourteen"
Case "15": xxb = "fivteen"
Case "16": xxb = "sixteen"
Case "17": xxb = "seventeen"
Case "18": xxb = "eighteen"
Case "19": xxb = "nineteen"
End Select
End Function
Public Function xx_2(num As String) As String
If CInt(num) < 10 Then
xx_2 = x(num)
Else
If CInt(num) < 20 Then
xx_2 = xxb(num)
Else
xx_2 = xxa(Left(num, 1)) + " " + x(Right(num, 1))
End If
End If
End Function
Public Function xx_3(num As String) As String
If IsNull(num) Then
Exit Function
End If

If CInt(num) < 999 And CInt(num) >= 100 Then
xx_3 = x(Left(num, 1)) + " hundred " + xx_2(Right(num, 2))
Else
If CInt(num) < 100 Then
xx_3 = xx_2(num)
End If
End If
End Function
Public Function xx_m(num As Currency) As String

Dim str_dollars As String
Dim str_cents As String
Dim str_dollars_len As Integer
Dim str_result As String
str_cents = Right(Format(num, ".00"), 2)
str_dollars = Left(Format(num, ".00"), Len(Format(num, ".00")) - 3)
str_dollars_len = Len(str_dollars)

If str_dollars_len <= 3 Then
xx_m = xx_3(str_dollars) + " dollars and " + xx_3(str_cents) + " cents"
Else
If (str_dollars_len Mod 3) <> 0 Then
If str_dollars_len < 6 And str_dollars_len <> 6 Then
xx_m = xx_3(Left(str_dollars, str_dollars_len Mod 3)) + " thousand " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1, 3)) + " dollars and " + xx_3(str_cents) + " cents"
Else
If str_dollars_len < 9 And str_dollars_len <> 9 Then
xx_m = xx_3(Left(str_dollars, str_dollars_len Mod 3)) + " million " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1, 3)) + " thousand " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1 + 3, 3)) + " dollars and " + xx_3(str_cents) + " cents"
Else
If str_dollars_len < 12 And str_dollars <> 12 Then
xx_m = xx_3(Left(str_dollars, str_dollars_len Mod 3)) + " billion " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1, 3)) + " million " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1 + 3, 3)) + " thousand " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1 + 3 + 3 + 3, 3)) + " dollars and " + xx_3(str_cents) + " cents"
Else
If str_dollars_len < 15 And str_dollars <> 15 Then
xx_m = xx_3(Left(str_dollars, str_dollars_len Mod 3)) + " trillion " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1, 3)) + " billion " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1 + 3, 3)) + " million " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1 + 3 + 3, 3)) + " thousand " + xx_3(Mid(str_dollars, (str_dollars_len Mod 3) + 1 + 3 + 3 + 3, 3)) + " dollars and " + xx_3(str_cents) + " cents "
End If
End If
End If
End If
End If
End If
'-------------------------------------------------
If (str_dollars_len > 3) And ((str_dollars_len Mod 3) = 0) Then
If str_dollars_len = 6 Then
xx_m = xx_3(Left(str_dollars, 3)) + " thousand " + xx_3(Mid(str_dollars, 1 + 3, 3)) + " dollars and " + xx_3(str_cents) + " cents"
Else
If str_dollars_len = 9 Then
xx_m = xx_3(Left(str_dollars, 3)) + " million " + xx_3(Mid(str_dollars, 1 + 3, 3)) + " thousand " + xx_3(Mid(str_dollars, 1 + 3 + 3, 3)) + " dollars and " + xx_3(str_cents) + " cents"
Else
If str_dollars_len = 12 Then
xx_m = xx_3(Left(str_dollars, 3)) + " billion " + xx_3(Mid(str_dollars, 1 + 3, 3)) + " million " + xx_3(Mid(str_dollars, 1 + 3 + 3, 3)) + " thousand " + xx_3(Mid(str
4#
 楼主| 发表于 2003-10-11 18:36:00 | 只看该作者
谢谢andymark,我去试试
5#
 楼主| 发表于 2003-10-11 18:39:00 | 只看该作者
遇到问题了,我是个新手有点搞不清楚,源码中的x,x_2,x_3,x_m,xxa,xxb都代表什么意思啊
6#
发表于 2003-10-11 18:54:00 | 只看该作者
定义数的位置
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-11-16 08:37 , Processed in 0.072580 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表