VB将数字翻译成英文

更新时间:2023-05-14 01:20:45 阅读: 评论:0

自动挡车档位介绍图
VB将数字翻译成英文
下面是一个将阿拉伯数字转换成英文说法的VB代码,源程序默认将小数点后面也翻译成英文
附源代码:
'****************' Main Function *'****************
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Application.Volatile True
Place(2) = " Thousand "
Select Ca Cents
Ca """"
Place(3) = " Million "
Place(4) = " Billion "
vivo手机开不了机怎么办Place(5) = " Trillion " ' String reprentation of amount
MyNumber = Trim(Str(MyNumber)) ' Position of decimal place 0 if none
DecimalPlace = InStr(MyNumber, ".")
'Convert cents and t 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)
El
MyNumber = ""
End If
Count = Count + 1
Loop
Select Ca Dollars
Ca ""
Dollars = "No Dollars"
无毒不丈夫是什么意思Ca "One"
Dollars = "One Dollar"
Ca El
Dollars = Dollars & " Dollars"
End Select
Cents = " and No Cents"
Ca "One"
Cents = " and One Cent"
Ca El
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Dollars & Cents
End Function
'*******************************************
' 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))
El
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Result
End Function
'*********************************************
' 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 Ca Val(TensText)
Ca 10: Result = "Ten"
Ca 11: Result = "Eleven"
Ca 12: Result = "Twelve"
Ca 13: Result = "Thirteen"
Ca 14: Result = "Fourteen"
Ca 15: Result = "Fifteen"
Ca 16: Result = "Sixteen"
Ca 17: Result = "Seventeen"
Ca 18: Result = "Eighteen"
Ca 19: Result = "Nineteen"
Ca El
End Select
荆棘鸟简介
El ' If value between 20-99 Select Ca Val(Left(TensText, 1))
Ca 2: Result = "Twenty "
Ca 3: Result = "Thirty "
Ca 4: Result = "Forty "
Ca 5: Result = "Fifty "
Ca 6: Result = "Sixty "
Ca 7: Result = "Seventy "
Ca 8: Result = "Eighty "
Ca 9: Result = "Ninety "
Ca El
End Select
Result = Result & GetDigit _
鉴赏是什么意思
(Right(TensText, 1)) 'Retrieve ones place
End If
GetTens = Result
End Function
'*******************************************
' Converts a number from 1 to 9 into text. *
'******************************************* Function GetDigit(Digit)
Select Ca Val(Digit)
Ca 1: GetDigit = "One"
Ca 2: GetDigit = "Two"
Ca 3: GetDigit = "Three"
Ca 4: GetDigit = "Four"
Ca 5: GetDigit = "Five"
Ca 6: GetDigit = "Six"
Ca 7: GetDigit = "Seven"
安徒生童话好词好句Ca 8: GetDigit = "Eight"
Ca 9: GetDigit = "Nine"
Ca El: GetDigit = ""
End Select
End Function
会员制营销方案

本文发布于:2023-05-14 01:20:45,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/620842.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:代码   默认   源程序   自动   营销   手机   美国
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图