convert numbers to words Indian system

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bijondhanbad
    New Member
    • Sep 2006
    • 8

    convert numbers to words Indian system

    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.
  • PEB
    Recognized Expert Top Contributor
    • Aug 2006
    • 1418

    #2
    Ehha! The regional settings also can't help you!

    And this have to be string!!! And not number!

    Comment

    • PEB
      Recognized Expert Top Contributor
      • Aug 2006
      • 1418

      #3
      So the virgulas are after the first 3 numbers from the right and 2 after each next couple isn't it?

      Comment

      • PEB
        Recognized Expert Top Contributor
        • Aug 2006
        • 1418

        #4
        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 ?

        Comment

        • bijondhanbad
          New Member
          • Sep 2006
          • 8

          #5
          Originally posted by 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 ?
          -----------------

          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,0 00 11 100,000,000,000 (One hundred billion)
          neel 1,00,00,00,00,0 0,000 13 10,000,000,000, 000 (Ten trillion)
          padma 1,00,00,00,00,0 0,00,000 15 1,000,000,000,0 00,000 (One
          quadrillion)

          Comment

          • PEB
            Recognized Expert Top Contributor
            • Aug 2006
            • 1418

            #6
            Originally posted by bijondhanbad
            -----------------

            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,0 00 11 100,000,000,000 (One hundred billion)
            neel 1,00,00,00,00,0 0,000 13 10,000,000,000, 000 (Ten trillion)
            padma 1,00,00,00,00,0 0,00,000 15 1,000,000,000,0 00,000 (One
            quadrillion)
            Ok!
            Espessially for you I've wrote this code! Try it and say if it is good! :)

            Code:
            Function indian_number(my_number) As String
            Dim result As String
            Dim new_result As String
            Dim i As Integer
            Dim last_i As Integer
            result = my_number
            result = Replace(result, ",", ".")
            'Stop
            If InStr(1, result, ".") Then
                new_result = Mid(result, InStr(1, result, "."), Len(result) - InStr(1, result, ".") + 1)
                result = Mid(result, 1, InStr(1, result, ".") - 1)
            End If
            
            For i = 1 To Len(result)
                If (i = 3) And Len(result) > 3 Then
                    new_result = "," + Mid(result, Len(result) - 2, Len(result)) + new_result
                    last_i = i
                End If
                If (i > 3) And (Len(result) > i) And ((i Mod 2) > 0) Then
                    new_result = "," + Mid(result, Len(result) - i + 1, i - last_i) + new_result
                    last_i = i
                End If
            Next i
            new_result = Mid(result, 1, Len(result) - last_i) + new_result
            indian_number = new_result
            End Function
            Have a nice day!

            :)

            Comment

            • PEB
              Recognized Expert Top Contributor
              • Aug 2006
              • 1418

              #7
              Or you are searching a code that says the numbers with words?

              I have mine in bulgarian...

              but in English!!!

              Comment

              • PEB
                Recognized Expert Top Contributor
                • Aug 2006
                • 1418

                #8
                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!

                :)

                Comment

                • PEB
                  Recognized Expert Top Contributor
                  • Aug 2006
                  • 1418

                  #9
                  Type the following code into the module sheet.


                  Code:
                  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 Dollars"
                                Case "One"
                                    Dollars = "One Dollar"
                                Case Else
                                    Dollars = Dollars & " Dollars"
                            End Select
                  
                            Select Case Cents
                                Case ""
                                    Cents = " and No Cents"
                                Case "One"
                                    Cents = " and One Cent"
                                Case Else
                                    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))
                            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
                  So it is easy to change your manner of spelling isn't it?

                  :)

                  Comment

                  • bijondhanbad
                    New Member
                    • Sep 2006
                    • 8

                    #10
                    Originally posted by PEB
                    Ok!
                    Espessially for you I've wrote this code! Try it and say if it is good! :)

                    Code:
                    Function indian_number(my_number) As String
                    Dim result As String
                    Dim new_result As String
                    Dim i As Integer
                    Dim last_i As Integer
                    result = my_number
                    result = Replace(result, ",", ".")
                    'Stop
                    If InStr(1, result, ".") Then
                        new_result = Mid(result, InStr(1, result, "."), Len(result) - InStr(1, result, ".") + 1)
                        result = Mid(result, 1, InStr(1, result, ".") - 1)
                    End If
                    
                    For i = 1 To Len(result)
                        If (i = 3) And Len(result) > 3 Then
                            new_result = "," + Mid(result, Len(result) - 2, Len(result)) + new_result
                            last_i = i
                        End If
                        If (i > 3) And (Len(result) > i) And ((i Mod 2) > 0) Then
                            new_result = "," + Mid(result, Len(result) - i + 1, i - last_i) + new_result
                            last_i = i
                        End If
                    Next i
                    new_result = Mid(result, 1, Len(result) - last_i) + new_result
                    indian_number = new_result
                    End Function
                    Have a nice day!

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

                    Comment

                    • PEB
                      Recognized Expert Top Contributor
                      • Aug 2006
                      • 1418

                      #11
                      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...

                      :)

                      Comment

                      Working...