close

Please send me how to convert Rs. 1234.00 in Displays the number in text.
(One thousand two hundred thirty four INR in English text)

i getting in Baht in Thai Text but i need in English. How do i get it?

i am also using [=spellnumber(b14)] function but this function working only
one time for using.

'/=========================================/
'Main Function
Function SpellNumber(ByVal MyNumber As String, _
Optional CurrencyName As String, _
Optional DecimalName As String) As String
'based on function from Microsoft Website:
'support.microsoft.com/default.aspx?scid=kb;en-us;213360
'accurate to Sextillions...
' 999,999,999,999,999,999,999,999.99
'(because I don't know what comes after sextillion)
'
'MyNumber can either be directly entered into the funtion
' as a string or a number or a cell range such as
' SpellNumber(quot;123,456.00quot;) or
' SpellNumber(123456.00) or
' SpellNumber(C12)
'
'CurrencyName is an optional string parameter
' If entered, it will replace the default quot;Dollarquot;.
' For example, if you enter quot;Pesoquot;, that name will
' appear instead of 'Dollar'
'
'DecimalName is an optional string parameter
' If entered, it will replace the default quot;Centquot;.
' For example, if you enter quot;Pesarquot;, that name will
' appear instead of 'Cent'
'
Dim Dollars, Cents, temp
Dim DecimalPlace, Count
Dim strCurrency As String, strDecimal As String
Dim strNegative As String

strCurrency = quot;Dollarquot;
strDecimal = quot;Centquot;
strNegative = quot;quot;

If Len(CurrencyName) lt;gt; 0 Then
strCurrency = Trim(CurrencyName)
End If

If Len(DecimalName) lt;gt; 0 Then
strDecimal = Trim(DecimalName)
End If

ReDim Place(9) As String

Place(2) = quot; Thousand quot;
Place(3) = quot; Million quot;
Place(4) = quot; Billion quot;
Place(5) = quot; Trillion quot;
Place(6) = quot; Quadrillion quot;
Place(7) = quot; Quintillion quot;
Place(8) = quot; Sextillion quot;

' String representation of amount because otherwise Excel
' represents large numbers using Scientific Notation
' such as 4.77874E 22 for 47,787,439,193,322,500,000,000.00
MyNumber = Format(MyNumber, quot;0,000.00quot;)

'get rid of extraneous data such as '$' or ','
MyNumber = StripOut(MyNumber)

'check for negative sign
If Left(MyNumber, 1) = quot;-quot; Then
strNegative = quot;Minus quot;
If Len(MyNumber) gt; 1 Then
MyNumber = Right(MyNumber, Len(MyNumber) - 1)
End If
End If

' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, quot;.quot;)

' Convert cents and set MyNumber to dollar amount.
If DecimalPlace gt; 0 Then
Cents = GetTens(Left(Mid(MyNumber, DecimalPlace 1) amp; _
quot;00quot;, 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
End If

Count = 1

Do While MyNumber lt;gt; quot;quot;
temp = GetHundreds(Right(MyNumber, 3))
If temp lt;gt; quot;quot; Then Dollars = temp amp; Place(Count) amp; Dollars
If Len(MyNumber) gt; 3 Then
MyNumber = Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber = quot;quot;
End If
Count = Count 1
Loop

Select Case Dollars
Case quot;quot;
Dollars = quot;No quot; amp; strCurrency amp; quot;squot;
Case quot;Onequot;
Dollars = quot;One quot; amp; strCurrency
Case Else
Dollars = Dollars amp; quot; quot; amp; strCurrency amp; quot;squot;
End Select

Select Case Cents
Case quot;quot;
Cents = quot; and No quot; amp; strDecimal amp; quot;squot;
Case quot;Onequot;
Cents = quot; and One quot; amp; strDecimal
Case Else
Cents = quot; and quot; amp; Cents amp; quot; quot; amp; strDecimal amp; quot;squot;
End Select

SpellNumber = strNegative amp; Dollars amp; Cents

End Function

'/=========================================/
' Converts a number from 100-999 into text
Private Function GetHundreds(ByVal MyNumber)
Dim Result As String

If Val(MyNumber) = 0 Then Exit Function

MyNumber = Right(quot;000quot; amp; MyNumber, 3)

' Convert the hundreds place.
If Mid(MyNumber, 1, 1) lt;gt; quot;0quot; Then
Result = GetDigit(Mid(MyNumber, 1, 1)) amp; quot; Hundred quot;
End If

' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) lt;gt; quot;0quot; Then
Result = Result amp; GetTens(Mid(MyNumber, 2))
Else
Result = Result amp; GetDigit(Mid(MyNumber, 3))
End If

GetHundreds = Result

End Function

'/=========================================/
' Converts a number from 10 to 99 into text.
Private Function GetTens(TensText)
Dim Result As String

Result = quot;quot; ' Null out the temporary function value.

If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result = quot;Tenquot;
Case 11: Result = quot;Elevenquot;
Case 12: Result = quot;Twelvequot;
Case 13: Result = quot;Thirteenquot;
Case 14: Result = quot;Fourteenquot;
Case 15: Result = quot;Fifteenquot;
Case 16: Result = quot;Sixteenquot;
Case 17: Result = quot;Seventeenquot;
Case 18: Result = quot;Eighteenquot;
Case 19: Result = quot;Nineteenquot;
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = quot;Twenty quot;
Case 3: Result = quot;Thirty quot;
Case 4: Result = quot;Forty quot;
Case 5: Result = quot;Fifty quot;
Case 6: Result = quot;Sixty quot;
Case 7: Result = quot;Seventy quot;
Case 8: Result = quot;Eighty quot;
Case 9: Result = quot;Ninety quot;
Case Else
End Select

Result = Result amp; GetDigit _
(Right(TensText, 1)) ' Retrieve ones place.

End If

GetTens = Result

End Function

'/=========================================/
' Converts a number from 1 to 9 into text.
Private Function GetDigit(Digit)
Select Case Val(Digit)
Case 1: GetDigit = quot;Onequot;
Case 2: GetDigit = quot;Twoquot;
Case 3: GetDigit = quot;Threequot;
Case 4: GetDigit = quot;Fourquot;
Case 5: GetDigit = quot;Fivequot;
Case 6: GetDigit = quot;Sixquot;
Case 7: GetDigit = quot;Sevenquot;
Case 8: GetDigit = quot;Eightquot;
Case 9: GetDigit = quot;Ninequot;
Case Else: GetDigit = quot;quot;
End Select
End Function
'/=========================================/
Private Function StripOut(strNumber) As String
Dim iLen As Integer, i As Integer
Dim strInternationalDecimalSeparator As String
Dim strBuildNumber As String

iLen = Len(strNumber)

If iLen = 0 Then
StripOut = quot;quot;
Exit Function
End If

strBuildNumber = quot;quot;

strInternationalDecimalSeparator = _
Application.International(xlDecimalSeparator)

For i = 1 To iLen
Select Case Mid(strNumber, i, 1)
'test for numbers
Case quot;0quot;, quot;1quot;, quot;2quot;, quot;3quot;, quot;4quot;, quot;5quot;, quot;6quot;, quot;7quot;, quot;8quot;, quot;9quot;
strBuildNumber = strBuildNumber amp; Mid(strNumber, i, 1)
'test for sign and decimal separator
Case quot;-quot;, strInternationalDecimalSeparator
strBuildNumber = strBuildNumber amp; Mid(strNumber, i, 1)
Case Else
strBuildNumber = strBuildNumber
End Select
Next i

StripOut = strBuildNumber

End Function
'/=========================================/

Hope this is what you are looking for. Change 'Dollar' and 'Cent' to
whatever you need.
--
Gary Brown

If this post was helpful, please click the ''Yes'' button next to ''Was this
Post Helpfull to you?''.quot;Ashish Patelquot; wrote:

gt; Please send me how to convert Rs. 1234.00 in Displays the number in text.
gt; (One thousand two hundred thirty four INR in English text)
gt;
gt; i getting in Baht in Thai Text but i need in English. How do i get it?
gt;
gt; i am also using [=spellnumber(b14)] function but this function working only
gt; one time for using.

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()