VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Translate Numeric Values in Words upto 99lakhs including paise. Easy for accounting purpose.

by Upendra Kolte (2 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 4th January 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Translate Numeric Values in Words upto 99lakhs including paise. Easy for accounting purpose.

API Declarations


'where u want to Translate numeric values in words. Pass numeric value in
'function it returns string as in words. eg. NUMBER: 2134 ANSWER: Two Thousand
'One Hundred Thirty Four Only. Its limit is upto 99Lakhs and it even converts
'paises for indian currency. for dollars and pounds just replace output string
'commented below final output for rupees and paise in code. for futher
'information contact [email protected]

Rate Translate Numeric Values in Words upto 99lakhs including paise. Easy for accounting purpose.



' Function to convert numerical value in words
Dim One_Ch As String
Dim Chk_Pos As String
Dim temp As String
Dim Paise As String
Dim Rupees As String
Dim i As Integer
i = 1
'temp = str_Num
Paise = ""
Temp1 = ""

For L = 1 To Len(str_Num)
    Temp1 = Mid(str_Num, L, 1)
    If Temp1 = "." Then
        DOT = 1
    Else
        If DOT <> 1 Then
            Rupees = Rupees + Temp1
        Else
            Paise = Paise + Temp1
        End If
    End If
    
Next
' For Rupees
temp = Rupees
 While Len(temp) <> 0
 
    One_Ch = Mid(Rupees, i, 1)
    
    'Detecting tens of the number
   If One_Ch <> "0" Then
        Select Case Len(temp)
            Case 7
                Num_In_Words = Num_In_Words & Conv_Word(One_Ch, 7, Mid(temp, 2, 1))
                Chk_Pos = One_Ch
                
            Case 6
                If Chk_Pos = "1" Then
                    Num_In_Words = Num_In_Words & " Lakhs "
                    ZeroErr = 1
                    Else
                            Num_In_Words = Num_In_Words & Conv_Word(One_Ch, 6) & " Lakhs "
                            ZeroErr = 1
                End If
            Case 5
                Num_In_Words = Num_In_Words & Conv_Word(One_Ch, 5, Mid(temp, 2, 1)) & " "
                Chk_Pos = One_Ch
                
            Case 4
                If Chk_Pos = "1" Then
                    Num_In_Words = Num_In_Words & " Thousand "
                    
                Else
                    Num_In_Words = Num_In_Words & Conv_Word(One_Ch, 4) & " Thousand "
                    
                End If
             
            Case 3
                Num_In_Words = Num_In_Words & Conv_Word(One_Ch, 3) & " Hundred "
                Chk_Pos = ""
                
            Case 2
                Num_In_Words = Num_In_Words & Conv_Word(One_Ch, 2, Mid(temp, 2, 1)) & " "
                Chk_Pos = One_Ch
            Case 1
                If Chk_Pos <> "1" Then _
                Num_In_Words = Num_In_Words & Conv_Word(One_Ch, 1)
          
        End Select
   Else
    Select Case Len(temp)
        Case 6
            If Mid(temp, 1, 1) = 0 Then Num_In_Words = Num_In_Words & " Lakhs "
'            If ZeroErr <> 1 Then _
'                Num_In_Words = Num_In_Words & " Lakhs "
            
        Case 4
            If Mid(temp, 1, 1) = 0 Then Num_In_Words = Num_In_Words & " Thousand "
'            If ZeroErr <> 1 Then _
'            Num_In_Words = Num_In_Words & " Thousand "
        
    End Select
  
   End If
    i = i + 1
   temp = Mid(Rupees, i, Len(temp))
 
 Wend
'Final Output for rupees
 Num_In_Words = Num_In_Words & " Rupees "
 
 ' For Paise
 If Paise <> "" Then
    For L = 1 To 2
       One_Ch = Mid(Paise, L, 1)
       Select Case L
           Case 1
               Num_In_Words = Num_In_Words & " and " & Conv_Word(One_Ch, 2, Mid(Paise, 2, 1))
               Chk_Pos = One_Ch
           Case 2
           If Chk_Pos <> "1" And Chk_Pos <> "0" Then _
               Num_In_Words = Num_In_Words & " " & Conv_Word(One_Ch, 1)
       End Select
    Next
'Final Output for paise
    Num_In_Words = Num_In_Words & " Paise"
 End If
 Num_In_Words = Num_In_Words & " Only."
End Function

Public Function Conv_Word(One_Ch As String, Pos As Integer, Optional NextChar As String) As String
'Converting numeric in words
If Pos <> 2 And Pos <> 5 And Pos <> 7 Then
    Select Case One_Ch
        Case "1"
            Conv_Word = "One"
        Case "2"
            Conv_Word = "Two"
        Case "3"
            Conv_Word = "Three"
        Case "4"
            Conv_Word = "Four"
        Case "5"
            Conv_Word = "Five"
        Case "6"
            Conv_Word = "Six"
        Case "7"
            Conv_Word = "Seven"
        Case "8"
            Conv_Word = "Eight"
        Case "9"
            Conv_Word = "Nine"
        'Case "0"
         '   Conv_Word = "Zero"
        
    End Select
Else
    Select Case One_Ch
        Case "1"
            Select Case NextChar
                Case "1"
                    Conv_Word = "Eleven"
                
                Case "2"
                    Conv_Word = "Twelve"
                
                Case "3"
                    Conv_Word = "Thirteen"
                
                Case "4"
                    Conv_Word = "Fourteen"
                
                Case "5"
                    Conv_Word = "Fifteen"
                
                Case "6"
                    Conv_Word = "Sixteen"
                
                Case "7"
                    Conv_Word = "Seventeen"
                
                Case "8"
                    Conv_Word = "Eighteen"
                
                Case "9"
                    Conv_Word = "Ninteen"
                
                Case "0"
                    Conv_Word = "Ten"

            End Select
        
        Case "2"
            Conv_Word = "Twenty"
        
        Case "3"
            Conv_Word = "Thirty"
        
        Case "4"
            Conv_Word = "Fourty"
        
        Case "5"
            Conv_Word = "Fifty"
        
        Case "6"
            Conv_Word = "Sixty"
        
        Case "7"
            Conv_Word = "Seventy"
        
        Case "8"
            Conv_Word = "Eighty"
        
        Case "9"
            Conv_Word = "Ninty"
        
        Case "0"
            Conv_Word = "Zero"
        
    End Select
End If
End Function



Download this snippet    Add to My Saved Code

Translate Numeric Values in Words upto 99lakhs including paise. Easy for accounting purpose. Comments

No comments have been posted about Translate Numeric Values in Words upto 99lakhs including paise. Easy for accounting purpose.. Why not be the first to post a comment about Translate Numeric Values in Words upto 99lakhs including paise. Easy for accounting purpose..

Post your comment

Subject:
Message:
0/1000 characters