Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) = " Thousand "
Place(3) = " Million "
Place(4) = " Billion "
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
Select Ca Cents
Ca ""
Cents = " and No Cents"
Ca "One"高中数学教材人教版
Cents = " and One Cent"
Ca El
Cents = " and " & Cents & " Cents"
End Select
SpellNumber = Dollars & Centsbartholin
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 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"
beach是什么意思Ca 18: Result = "Eighteen"
Ca 19: Result = "Nineteen"
Ca Elimerj
End Select
El ' If value 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
majoringResult = 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"visible
Ca 6: GetDigit = "Six"
Ca 7: GetDigit = "Seven"
Ca 8: GetDigit = "Eight"
Ca 9: GetDigit = "Nine"
Ca El: GetDigit = ""
End Select
End Function
徐彩玉 2011-7-17 16:35:13
我发给你的表格中已经插入代码,里面有模块
sandwich