Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello i want to convert the number in hindi word . i got some codes from here . but i m not getting how to use it plz help me to run the code..


Private Function HindiStyle() As String
       Dim amountString As String = Amount.ToString

       If Amount = 0 Then Return "शून्य" 'Unique and exceptional case
       If amountString.Length > 15 Then Return "That's too long..."

       Dim amountArray() As Integer = NumberToArray(amountString)

       Dim j As Integer = 0
       Dim digit As Integer = 0
       Dim result As String = ""
       Dim separator As String = ""
       Dim higherDigitHindiString As String = ""
       Dim codeIndex As String = ""


       For i As Integer = amountArray.Length To 1 Step -1
           j = amountArray.Length - i
           digit = amountArray(j)


           higherDigitHindiString = HigherDigitHindiNumberArray(CInt(codeIndex.Substring(0, 1)) - 1)


           If codeIndex = "1" Then 'Number [1, 9]
               result = result & separator & HundredHindiDigitArray(digit)

           ElseIf codeIndex.Length = 2 And digit <> 0 Then 'Number in tenth place and skip if digit is 0
               Dim suffixDigit As Integer = amountArray(j + 1)
               Dim wholeTenthPlaceDigit As Integer = digit * 10 + suffixDigit

               result = result & separator & HundredHindiDigitArray(wholeTenthPlaceDigit) & " " & higherDigitHindiString
               i -= 1

           ElseIf digit <> 0 Then  'Standard Number like 100, 1000, 1000000 and skip if digit is 0
               result = result & separator & HundredHindiDigitArray(digit) & " " & higherDigitHindiString
           End If

           separator = " "
       Next

       Return RemoveSpaces(result)
   End Function

   'Formatting Number "

   Private Function FormatNumberPerLanguage(ByVal culterInfoName As String)
       Dim ci As New System.Globalization.CultureInfo(culterInfoName)
       ci.NumberFormat.NumberDecimalDigits = 0
       Return Me.Amount.ToString("N", ci)
   End Function

   '#End Region

   Private Function NumberToArray(ByVal amountString As String) As Integer()
       Dim amountArray(amountString.Length - 1) As Integer
       For i As Integer = amountArray.Length To 1 Step -1
           amountArray(i - 1) = amountString.Substring(i - 1, 1)
       Next
       Return amountArray
   End Function

   Private Function RemoveSpaces(ByVal word As String) As String
       Dim regEx As New System.Text.RegularExpressions.Regex("  ")
       Return regEx.Replace(word, " ").Trim
   End Function

   '#End Region


   '#Region " Property"

   Public ReadOnly Property Amount As Long
       Get
           Return m_amount
       End Get
   End Property


   '#End Region


   '#Region " Fields"

   Private m_amount As Long



   Private HundredHindiDigitArray() = _
           {"", "एक", "दो", "तीन", "चार", "पाँच", "छह", "सात", "आठ", "नौ", "दस", _
           "ग्यारह", "बारह", "तेरह", "चौदह", "पन्द्रह", "सोलह", "सत्रह", "अठारह", "उन्नीस", "बीस", _
           "इक्कीस", "बाईस", "तेईस", "चौबीस", "पच्चीस", "छब्बीस", "सत्ताईस", "अट्ठाईस", "उनतीस", "तीस", _
           "इकतीस", "बत्तीस", "तैंतीस", "चौंतीस", "पैंतीस", "छत्तीस", "सैंतीस", "अड़तीस", "उनतालीस", "चालीस", _
           "इकतालीस", "बयालीस", "तैंतालीस", "चौवालीस", "पैंतालीस", "छियालीस", "सैंतालीस", "अड़तालीस", "उनचास", "पचास", _
           "इक्यावन", "बावन", "तिरेपन", "चौवन", "पचपन", "छप्पन", "सत्तावन", "अट्ठावन", "उनसठ", "साठ", _
           "इकसठ", "बासठ", "तिरेसठ", "चौंसठ", "पैंसठ", "छियासठ", "सड़सठ", "अड़सठ", "उनहत्तर", "सत्तर", _
           "इकहत्तर", "बहत्तर", "तिहत्तर", "चौहत्तर", "पचहत्तर", "छिहत्तर", "सतहत्तर", "अठहत्तर", "उनासी", "अस्सी", _
           "इक्यासी", "बयासी", "तिरासी", "चौरासी", "पचासी", "छियासी", "सत्तासी", "अट्ठासी", "नवासी", "नब्बे", _
           "इक्यानबे", "बानबे", "तिरानबे", "चौरानबे", "पंचानबे", "छियानबे", "सत्तानबे", "अट्ठानबे", "निन्यानबे"}

   Private HigherDigitHindiNumberArray() = {"", "", "सौ", "हजार", "लाख", "करोड़", "अरब", "खरब", "नील"}
Posted
Comments
Richard MacCutchan 3-May-15 8:20am    
You need to ask a proper question.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900