How to change Number into words

M

muddan madhu

source http://support.microsoft.com/kb/213360

i have disabled paise part.

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 representation of amount.
MyNumber = Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace = InStr(MyNumber, ".")
' Convert cents and set 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)
Else
MyNumber = ""
End If
Count = Count + 1
Loop
Select Case Dollars
Case ""
Dollars = "No Rupee"
Case "One"
Dollars = "One Rupee"
Case Else
Dollars = Dollars & " Rupees"
End Select
Select Case Cents
Case ""
Cents = " and No Paise"
Case "One"
Cents = " and One Paise"
Case Else
Cents = " and " & Cents & " Paise"
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))
Else
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 Case Val(TensText)
Case 10: Result = "Ten"
Case 11: Result = "Eleven"
Case 12: Result = "Twelve"
Case 13: Result = "Thirteen"
Case 14: Result = "Fourteen"
Case 15: Result = "Fifteen"
Case 16: Result = "Sixteen"
Case 17: Result = "Seventeen"
Case 18: Result = "Eighteen"
Case 19: Result = "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result = "Twenty "
Case 3: Result = "Thirty "
Case 4: Result = "Forty "
Case 5: Result = "Fifty "
Case 6: Result = "Sixty "
Case 7: Result = "Seventy "
Case 8: Result = "Eighty "
Case 9: Result = "Ninety "
Case Else
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 Case Val(Digit)
Case 1: GetDigit = "One"
Case 2: GetDigit = "Two"
Case 3: GetDigit = "Three"
Case 4: GetDigit = "Four"
Case 5: GetDigit = "Five"
Case 6: GetDigit = "Six"
Case 7: GetDigit = "Seven"
Case 8: GetDigit = "Eight"
Case 9: GetDigit = "Nine"
Case Else: GetDigit = ""
End Select
End Function
 
R

rajan deshpande

dear friend i found this addin on net. thanks to Mr. Suresh who prepared this. let me know how to upload this. also i have my own zip file to convert numbers to words ( not as good as Mr. Suresh's )

rajan



Prince Kumar wrote:

How to change Number into words
22-Oct-09

Please suggest me to Foumula, If i write amount Rs. 50,000.00 to change this into (Fifty Thousand)

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
LOST IN SPACE FOREVER! (compressed DataSet)
http://www.eggheadcafe.com/tutorial...fed-afdbc8ce7d1f/lost-in-space-forever-c.aspx
 
R

rajan deshpande

dear friend i found this addin on net. thanks to Mr. Suresh who prepared this. let me know how to upload this. also i have my own zip file to convert numbers to words ( not as good as Mr. Suresh's )

rajan



Prince Kumar wrote:

How to change Number into words
22-Oct-09

Please suggest me to Foumula, If i write amount Rs. 50,000.00 to change this into (Fifty Thousand)

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
Wise for Visual Studio .NET
http://www.eggheadcafe.com/tutorial...39-75a1f1aae2e2/wise-for-visual-studio-n.aspx
 
R

raju nsl

Hi,

suresh how to chenge number into words in excel



Prince Kumar wrote:

How to change Number into words
22-Oct-09

Please suggest me to Foumula, If i write amount Rs. 50,000.00 to change this into (Fifty Thousand)

EggHeadCafe - Software Developer Portal of Choice
Create the Signature of XML file
http://www.eggheadcafe.com/tutorial...a-a44eb4b902cb/create-the-signature-of-x.aspx

Previous Posts In This Thread:

How to change Number into words
Please suggest me to Foumula, If i write amount Rs. 50,000.00 to change this into (Fifty Thousand)

EggHeadCafe - Software Developer Portal of Choice
Create the Signature of XML file
http://www.eggheadcafe.com/tutorial...a-a44eb4b902cb/create-the-signature-of-x.aspx

source http://support.microsoft.com/kb/213360i have disabled paise part.
source http://support.microsoft.com/kb/213360

i have disabled paise part.

Option Explicit
'Main Function
Function SpellNumber(ByVal MyNumber)
Dim Dollars, Cents, Temp
Dim DecimalPlace, Count
ReDim Place(9) As String
Place(2) =3D " Thousand "
Place(3) =3D " Million "
Place(4) =3D " Billion "
Place(5) =3D " Trillion "
' String representation of amount.
MyNumber =3D Trim(Str(MyNumber))
' Position of decimal place 0 if none.
DecimalPlace =3D InStr(MyNumber, ".")
' Convert cents and set MyNumber to dollar amount.
If DecimalPlace > 0 Then
Cents =3D GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
"00", 2))
MyNumber =3D Trim(Left(MyNumber, DecimalPlace - 1))
End If
Count =3D 1
Do While MyNumber <> ""
Temp =3D GetHundreds(Right(MyNumber, 3))
If Temp <> "" Then Dollars =3D Temp & Place(Count) & Dollars
If Len(MyNumber) > 3 Then
MyNumber =3D Left(MyNumber, Len(MyNumber) - 3)
Else
MyNumber =3D ""
End If
Count =3D Count + 1
Loop
Select Case Dollars
Case ""
Dollars =3D "No Rupee"
Case "One"
Dollars =3D "One Rupee"
Case Else
Dollars =3D Dollars & " Rupees"
End Select
Select Case Cents
Case ""
Cents =3D " and No Paise"
Case "One"
Cents =3D " and One Paise"
Case Else
Cents =3D " and " & Cents & " Paise"
End Select
SpellNumber =3D Dollars '& Cents
End Function

' Converts a number from 100-999 into text
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) =3D 0 Then Exit Function
MyNumber =3D Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) <> "0" Then
Result =3D GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) <> "0" Then
Result =3D Result & GetTens(Mid(MyNumber, 2))
Else
Result =3D Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds =3D Result
End Function

' Converts a number from 10 to 99 into text.
Function GetTens(TensText)
Dim Result As String
Result =3D "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) =3D 1 Then ' If value between 10-19...
Select Case Val(TensText)
Case 10: Result =3D "Ten"
Case 11: Result =3D "Eleven"
Case 12: Result =3D "Twelve"
Case 13: Result =3D "Thirteen"
Case 14: Result =3D "Fourteen"
Case 15: Result =3D "Fifteen"
Case 16: Result =3D "Sixteen"
Case 17: Result =3D "Seventeen"
Case 18: Result =3D "Eighteen"
Case 19: Result =3D "Nineteen"
Case Else
End Select
Else ' If value between 20-99...
Select Case Val(Left(TensText, 1))
Case 2: Result =3D "Twenty "
Case 3: Result =3D "Thirty "
Case 4: Result =3D "Forty "
Case 5: Result =3D "Fifty "
Case 6: Result =3D "Sixty "
Case 7: Result =3D "Seventy "
Case 8: Result =3D "Eighty "
Case 9: Result =3D "Ninety "

numbers to words
dear friend i found this addin on net. thanks to Mr. Suresh who prepared this. let me know how to upload this. also i have my own zip file to convert numbers to words ( not as good as Mr. Suresh's )

rajan



Prince Kumar wrote:

How to change Number into words
22-Oct-09

Please suggest me to Foumula, If i write amount Rs. 50,000.00 to change this into (Fifty Thousand)

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
LOST IN SPACE FOREVER! (compressed DataSet)
http://www.eggheadcafe.com/tutorial...fed-afdbc8ce7d1f/lost-in-space-forever-c.aspx

numbers to words
dear friend i found this addin on net. thanks to Mr. Suresh who prepared this. let me know how to upload this. also i have my own zip file to convert numbers to words ( not as good as Mr. Suresh's )

rajan



Prince Kumar wrote:

How to change Number into words
22-Oct-09

Please suggest me to Foumula, If i write amount Rs. 50,000.00 to change this into (Fifty Thousand)

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
Wise for Visual Studio .NET
http://www.eggheadcafe.com/tutorial...39-75a1f1aae2e2/wise-for-visual-studio-n.aspx

Free ASAP Utilities offers this function. See:http://www.asap-utilities.
Free ASAP Utilities offers this function. See:
http://www.asap-utilities.com/

Eric

<Prince Kumar> wrote in message


Submitted via EggHeadCafe - Software Developer Portal of Choice
Working with Compressed Resources in .NET
http://www.eggheadcafe.com/tutorial...0-c314ccfc92e8/working-with-compressed-r.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top