By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,918 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,918 IT Pros & Developers. It's quick & easy.

convert numbers to words Indian system

P: 8
If any one can can help me out with a function or module to convert numbers to words in the Indian system of numerals..........
Like 1,24,53,432 will read as one crore twenty four lakhs fifty three thousand four hundred and thirty two.
Sep 8 '06 #1
Share this Question
Share on Google+
10 Replies


PEB
Expert 100+
P: 1,418
PEB
Ehha! The regional settings also can't help you!

And this have to be string!!! And not number!
Sep 8 '06 #2

PEB
Expert 100+
P: 1,418
PEB
So the virgulas are after the first 3 numbers from the right and 2 after each next couple isn't it?
Sep 9 '06 #3

PEB
Expert 100+
P: 1,418
PEB
And this number is it good?

24,86,54,54,421

And when there is a decimals what are you doing? You use the . maybe like this:

24,86,54,54,421.56 ?
Sep 9 '06 #4

P: 8
And this number is it good?

24,86,54,54,421

And when there is a decimals what are you doing? You use the . maybe like this:

24,86,54,54,421.56 ?
-----------------

Yes you are right. A brief intro to the Indian number system is shown below :

Indian numbering system is used today in India, Pakistan, Bangladesh, and Myanmar (Burma) and is based on a unique grouping of 2 decimal places, rather than the 3 decimal places commonplace in the West (China and Japan, for instance, use 4). The terms crore and lakh are in widespread use today in Indian English.
The table below follows the short scale usage of billion being a thousand million. In India, following British usage, the long scale was used, with one billion equivalent to a million million.
India's unique number system
Term Figure No of zeros Western system (short scale)
lakh (lac) 1,00,000 5 100,000 (One hundred thousand)
crore 1,00,00,000 7 10,000,000 (Ten million)
arab 1,00,00,00,000 9 1,000,000,000 (One billion)
kharab 1,00,00,00,00,000 11 100,000,000,000 (One hundred billion)
neel 1,00,00,00,00,00,000 13 10,000,000,000,000 (Ten trillion)
padma 1,00,00,00,00,00,00,000 15 1,000,000,000,000,000 (One
quadrillion)
Sep 10 '06 #5

PEB
Expert 100+
P: 1,418
PEB
-----------------

Yes you are right. A brief intro to the Indian number system is shown below :

Indian numbering system is used today in India, Pakistan, Bangladesh, and Myanmar (Burma) and is based on a unique grouping of 2 decimal places, rather than the 3 decimal places commonplace in the West (China and Japan, for instance, use 4). The terms crore and lakh are in widespread use today in Indian English.
The table below follows the short scale usage of billion being a thousand million. In India, following British usage, the long scale was used, with one billion equivalent to a million million.
India's unique number system
Term Figure No of zeros Western system (short scale)
lakh (lac) 1,00,000 5 100,000 (One hundred thousand)
crore 1,00,00,000 7 10,000,000 (Ten million)
arab 1,00,00,00,000 9 1,000,000,000 (One billion)
kharab 1,00,00,00,00,000 11 100,000,000,000 (One hundred billion)
neel 1,00,00,00,00,00,000 13 10,000,000,000,000 (Ten trillion)
padma 1,00,00,00,00,00,00,000 15 1,000,000,000,000,000 (One
quadrillion)
Ok!
Espessially for you I've wrote this code! Try it and say if it is good! :)

Expand|Select|Wrap|Line Numbers
  1. Function indian_number(my_number) As String
  2. Dim result As String
  3. Dim new_result As String
  4. Dim i As Integer
  5. Dim last_i As Integer
  6. result = my_number
  7. result = Replace(result, ",", ".")
  8. 'Stop
  9. If InStr(1, result, ".") Then
  10.     new_result = Mid(result, InStr(1, result, "."), Len(result) - InStr(1, result, ".") + 1)
  11.     result = Mid(result, 1, InStr(1, result, ".") - 1)
  12. End If
  13.  
  14. For i = 1 To Len(result)
  15.     If (i = 3) And Len(result) > 3 Then
  16.         new_result = "," + Mid(result, Len(result) - 2, Len(result)) + new_result
  17.         last_i = i
  18.     End If
  19.     If (i > 3) And (Len(result) > i) And ((i Mod 2) > 0) Then
  20.         new_result = "," + Mid(result, Len(result) - i + 1, i - last_i) + new_result
  21.         last_i = i
  22.     End If
  23. Next i
  24. new_result = Mid(result, 1, Len(result) - last_i) + new_result
  25. indian_number = new_result
  26. End Function
  27.  
Have a nice day!

:)
Sep 10 '06 #6

PEB
Expert 100+
P: 1,418
PEB
Or you are searching a code that says the numbers with words?

I have mine in bulgarian...

but in English!!!
Sep 10 '06 #7

PEB
Expert 100+
P: 1,418
PEB
IF is it your need I can write you the code but it's difficult and takes as well as 10 -12 hours!

It's better to search in the net!

IF you find a code that says the numbers in English maybe I could retreat it to display the numbers in indian English!

:)
Sep 10 '06 #8

PEB
Expert 100+
P: 1,418
PEB
Type the following code into the module sheet.


Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3.       '****************
  4.       ' Main Function *
  5.       '****************
  6.  
  7.       Function SpellNumber(ByVal MyNumber)
  8.           Dim Dollars, Cents, Temp
  9.           Dim DecimalPlace, Count
  10.  
  11.           ReDim Place(9) As String
  12.           Place(2) = " Thousand "
  13.           Place(3) = " Million "
  14.           Place(4) = " Billion "
  15.           Place(5) = " Trillion "
  16.  
  17.           ' String representation of amount.
  18.           MyNumber = Trim(Str(MyNumber))
  19.  
  20.           ' Position of decimal place 0 if none.
  21.           DecimalPlace = InStr(MyNumber, ".")
  22.           ' Convert cents and set MyNumber to dollar amount.
  23.           If DecimalPlace > 0 Then
  24.               Cents = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & _
  25.                   "00", 2))
  26.               MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))
  27.           End If
  28.  
  29.           Count = 1
  30.           Do While MyNumber <> ""
  31.               Temp = GetHundreds(Right(MyNumber, 3))
  32.               If Temp <> "" Then Dollars = Temp & Place(Count) & Dollars
  33.               If Len(MyNumber) > 3 Then
  34.                   MyNumber = Left(MyNumber, Len(MyNumber) - 3)
  35.               Else
  36.                   MyNumber = ""
  37.               End If
  38.               Count = Count + 1
  39.           Loop
  40.  
  41.           Select Case Dollars
  42.               Case ""
  43.                   Dollars = "No Dollars"
  44.               Case "One"
  45.                   Dollars = "One Dollar"
  46.               Case Else
  47.                   Dollars = Dollars & " Dollars"
  48.           End Select
  49.  
  50.           Select Case Cents
  51.               Case ""
  52.                   Cents = " and No Cents"
  53.               Case "One"
  54.                   Cents = " and One Cent"
  55.               Case Else
  56.                   Cents = " and " & Cents & " Cents"
  57.           End Select
  58.  
  59.           SpellNumber = Dollars & Cents
  60.       End Function
  61.  
  62.  
  63.  
  64.       '*******************************************
  65.       ' Converts a number from 100-999 into text *
  66.       '*******************************************
  67.  
  68.       Function GetHundreds(ByVal MyNumber)
  69.           Dim Result As String
  70.  
  71.           If Val(MyNumber) = 0 Then Exit Function
  72.           MyNumber = Right("000" & MyNumber, 3)
  73.  
  74.           ' Convert the hundreds place.
  75.           If Mid(MyNumber, 1, 1) <> "0" Then
  76.               Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
  77.           End If
  78.  
  79.           ' Convert the tens and ones place.
  80.           If Mid(MyNumber, 2, 1) <> "0" Then
  81.               Result = Result & GetTens(Mid(MyNumber, 2))
  82.           Else
  83.               Result = Result & GetDigit(Mid(MyNumber, 3))
  84.           End If
  85.  
  86.           GetHundreds = Result
  87.       End Function
  88.  
  89.  
  90.  
  91.       '*********************************************
  92.       ' Converts a number from 10 to 99 into text. *
  93.       '*********************************************
  94.  
  95.      Function GetTens(TensText)
  96.           Dim Result As String
  97.  
  98.           Result = ""           ' Null out the temporary function value.
  99.           If Val(Left(TensText, 1)) = 1 Then   ' If value between 10-19...
  100.               Select Case Val(TensText)
  101.                   Case 10: Result = "Ten"
  102.                   Case 11: Result = "Eleven"
  103.                   Case 12: Result = "Twelve"
  104.                   Case 13: Result = "Thirteen"
  105.                   Case 14: Result = "Fourteen"
  106.                   Case 15: Result = "Fifteen"
  107.                   Case 16: Result = "Sixteen"
  108.                   Case 17: Result = "Seventeen"
  109.                   Case 18: Result = "Eighteen"
  110.                   Case 19: Result = "Nineteen"
  111.                   Case Else
  112.               End Select
  113.           Else                                 ' If value between 20-99...
  114.               Select Case Val(Left(TensText, 1))
  115.                   Case 2: Result = "Twenty "
  116.                   Case 3: Result = "Thirty "
  117.                   Case 4: Result = "Forty "
  118.                   Case 5: Result = "Fifty "
  119.                   Case 6: Result = "Sixty "
  120.                   Case 7: Result = "Seventy "
  121.                   Case 8: Result = "Eighty "
  122.                   Case 9: Result = "Ninety "
  123.                   Case Else
  124.               End Select
  125.               Result = Result & GetDigit _
  126.                   (Right(TensText, 1))  ' Retrieve ones place.
  127.           End If
  128.           GetTens = Result
  129.       End Function
  130.  
  131.  
  132.  
  133.  
  134.       '*******************************************
  135.       ' Converts a number from 1 to 9 into text. *
  136.       '*******************************************
  137.  
  138.       Function GetDigit(Digit)
  139.           Select Case Val(Digit)
  140.               Case 1: GetDigit = "One"
  141.               Case 2: GetDigit = "Two"
  142.               Case 3: GetDigit = "Three"
  143.               Case 4: GetDigit = "Four"
  144.               Case 5: GetDigit = "Five"
  145.               Case 6: GetDigit = "Six"
  146.               Case 7: GetDigit = "Seven"
  147.               Case 8: GetDigit = "Eight"
  148.               Case 9: GetDigit = "Nine"
  149.               Case Else: GetDigit = ""
  150.           End Select
  151.       End Function
  152.  
  153.  
So it is easy to change your manner of spelling isn't it?

:)
Sep 10 '06 #9

P: 8
Ok!
Espessially for you I've wrote this code! Try it and say if it is good! :)

Expand|Select|Wrap|Line Numbers
  1. Function indian_number(my_number) As String
  2. Dim result As String
  3. Dim new_result As String
  4. Dim i As Integer
  5. Dim last_i As Integer
  6. result = my_number
  7. result = Replace(result, ",", ".")
  8. 'Stop
  9. If InStr(1, result, ".") Then
  10.     new_result = Mid(result, InStr(1, result, "."), Len(result) - InStr(1, result, ".") + 1)
  11.     result = Mid(result, 1, InStr(1, result, ".") - 1)
  12. End If
  13.  
  14. For i = 1 To Len(result)
  15.     If (i = 3) And Len(result) > 3 Then
  16.         new_result = "," + Mid(result, Len(result) - 2, Len(result)) + new_result
  17.         last_i = i
  18.     End If
  19.     If (i > 3) And (Len(result) > i) And ((i Mod 2) > 0) Then
  20.         new_result = "," + Mid(result, Len(result) - i + 1, i - last_i) + new_result
  21.         last_i = i
  22.     End If
  23. Next i
  24. new_result = Mid(result, 1, Len(result) - last_i) + new_result
  25. indian_number = new_result
  26. End Function
  27.  
Have a nice day!

:)
********************
Sorry, doesn't work.
Any way thanks.
got the code in another site codeproject.com and tip-teks.com
Sep 10 '06 #10

PEB
Expert 100+
P: 1,418
PEB
This code is to vizualize the number like 12.23.65.985
and not to tell you the number in words...

The code bellow is to convert the numbers in words... It is the same as in the others sites...

:)
Sep 10 '06 #11

Post your reply

Sign in to post your reply or Sign up for a free account.