设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

是否有函数将数值用英文读出来

[复制链接]
跳转到指定楼层
1#
发表于 2002-6-10 20:33:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求教各位高手,是否有函数能将数值用英文读出来:
如5236.00
FIVE THOUSAND TWO HUNDRED AND THIRTY-SIX.

如无此函数,有其他办法吗?[em26]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 2002-6-10 22:00:00 | 只看该作者
用人民币大写转换函数改一改应该可以用。
3#
发表于 2002-6-12 07:50:00 | 只看该作者
可以,但一切都要自己做。首先你要分析数字与英文读法的关系,再把每个基本的读音录下来变成WAV文件。然后写一个自定义函数,如 f (x)  .

f中使用API函数play??? (查查手册) 就可播放WAV文件。剩下的就是f的算法了。
4#
 楼主| 发表于 2002-6-12 16:19:00 | 只看该作者
对不起,我不是想把数值读出来,只要能够用英语在报表中显示出来即可。如在报表中添加一个文本框,其内容为某表中的对应数值的英文读法。

点击这里给我发消息

5#
发表于 2002-6-13 16:50:00 | 只看该作者
如果想读出来,IBM有个相应的语音软件,可根据它的接口来做
如果想转成英文写法,可仿照数字转中文的方法做个类似的。
6#
发表于 2002-6-15 19:48:00 | 只看该作者
有一个VB的代码,不知道有没有用
把数字转成英文字
●建立D2T巨集,并把快速键设为Shift + Ctrl + T。


●写入程式码:

Sub D2T()
Dim MyStr As String
MyStr = ActiveCell.Text

If IsNumeric(MyStr) = True Then
ActiveCell.Value = ""

Select Case Len(MyStr)
Case 1
OneDG (MyStr)
Case 2
TwoDG (MyStr)
Case 3
ThreeDG (MyStr)
Case 4
OneDG (Left(MyStr, 1))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 5
TwoDG (Left(MyStr, 2))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 6
ThreeDG (Left(MyStr, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 7
OneDG (Left(MyStr, 1))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 2, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 8
TwoDG (Left(MyStr, 2))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 3, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 9
ThreeDG (Left(MyStr, 3))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 4, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 10
OneDG (Left(MyStr, 1))
ActiveCell.Value = ActiveCell.Value + " Billon "
ThreeDG (Mid(MyStr, 2, 3))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 5, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case 11
TwoDG (Left(MyStr, 2))
ActiveCell.Value = ActiveCell.Value + " Billon "
ThreeDG (Mid(MyStr, 3, 3))
ActiveCell.Value = ActiveCell.Value + " Millon "
ThreeDG (Mid(MyStr, 6, 3))
ActiveCell.Value = ActiveCell.Value + " Thousand "
ThreeDG (Right(MyStr, 3))
Case Else
End Select
End If
End Sub

Sub OneDG(MyStr As String)
Select Case MyStr
Case "0"
If ActiveCell.Value = "" Then ActiveCell.Value = ActiveCell.Value + "Zero"
Case "1"
ActiveCell.Value = ActiveCell.Value + "One"
Case "2"
ActiveCell.Value = ActiveCell.Value + "Two"
Case "3"
ActiveCell.Value = ActiveCell.Value + "Three"
Case "4"
ActiveCell.Value = ActiveCell.Value + "Four"
Case "5"
ActiveCell.Value = ActiveCell.Value + "Five"
Case "6"
ActiveCell.Value = ActiveCell.Value + "Six"
Case "7"
ActiveCell.Value = ActiveCell.Value + "Seven"
Case "8"
ActiveCell.Value = ActiveCell.Value + "Eight"
Case "9"
ActiveCell.Value = ActiveCell.Value + "Nine"
End Select
End Sub

Sub TwoDG(MyStr As String)
Select Case MyStr
Case "10"
ActiveCell.Value = ActiveCell.Value + "Ten"
Case "11"
ActiveCell.Value = ActiveCell.Value + "eleven"
Case "12"
ActiveCell.Value = ActiveCell.Value + "Twelve"
Case "13"
ActiveCell.Value = ActiveCell.Value + "Thirteen"
Case "14"
ActiveCell.Value = ActiveCell.Value + "Fourteen"
Case "15"
ActiveCell.Value = ActiveCell.Value + "Fifteen"
Case "16"
ActiveCell.Value = ActiveCell.Value + "Sixteen"
Case "17"
ActiveCell.Value = ActiveCell.Value + "Seventeen"
Case "18"
ActiveCell.Value = ActiveCell.Value + "Eighteen"
Case "19"
ActiveCell.Value = ActiveCell.Value + "Nineteen"
Case Else
Select Case Left(MyStr, 1)
Case "2"
ActiveCell.Value = ActiveCell.Value + "Twenty "
Case "3"
ActiveCell.Value = ActiveCell.Value + "Thirty "
Case "4"
ActiveCell.Value = ActiveCell.Value + "Forty "
Case "5"
ActiveCell.Value = ActiveCell.Value + "Fifty "
Case "6"
ActiveCell.Value = ActiveCell.Value + "Sixty "
Case "7"
ActiveCell.Value = ActiveCell.Value + "Seventy "
Case "8"
ActiveCell.Value = ActiveCell.Value + "Eighty "
Case "9"
ActiveCell.Value = ActiveCell.Value + "Ninety "
End Select
OneDG (Right(MyStr, 1))
End Select

End Sub

Sub ThreeDG(MyStr As String)
Select Case Left(MyStr, 1)
Case "1"
ActiveCell.Value = ActiveCell.Value + "One Handred "
Case "2"
ActiveCell.Value = ActiveCell.Value + "Two Handred "
Case "3"
ActiveCell.Value = ActiveCell.Value + "Three Handred "
Case "4"
ActiveCell.Value = ActiveCell.Value + "Four Handred "
Case "5"
ActiveCell.Value = ActiveCell.Value + "Five Handred "
Case "6"
ActiveCell
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-1-11 02:54 , Processed in 0.125843 second(s), 29 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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