把数字转成英文字
2008-02-23 06:54:25来源:互联网 阅读 ()
●写入程式码:
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.Value = ActiveCell.Value "Six Handred "
Case "7"
ActiveCell.Value = ActiveCell.Value "Seven Handred "
Case "8"
ActiveCell.Value = ActiveCell.Value "Eight Handred "
Case "9"
ActiveCell.Value = ActiveCell.Value "Night Handred "
End Select
TwoDG Right(MyStr, 2)
End Sub
●上面的程式码可以处理到11位数。 ●随意输入一个未超过11位数的数字,然后把输入游标移到该Cell里。
●一同按下 Shift Ctrl T。
上一篇: 切分字符串
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:获得、设置鼠标双击间隔时间
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash