VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



------used recursive function------

by RAVI KC (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 28th March 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

------used recursive function------

API Declarations


---none----

Rate ------used recursive function------



Dim Istr As String
Dim nos
nos = CDbl(str1)
If Val(str1) = 0 Then
Exit Function
End If
Select Case nos
    Case 0 To 15
        Istr = Choose(nos + 1, " ", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen")
    Case 16 To 19
        Istr = Inwords(Right(nos, 1)) & "teen"
    Case 20, 30, 40, 50, 60, 70, 80, 90
        Istr = Choose(nos / 10, "RAVI", "Twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninty")
    Case 21 To 99
        Istr = Inwords(Left(nos, 1) & 0) & Inwords(Right(nos, 1))
    Case 101 To 999
    If CInt(nos) <> 0 Then
        Istr = Inwords(Left(nos, 1)) & " hundred  " & "  " & Inwords(Right(nos, 2))
   Else
           Istr = Inwords(Left(nos, 1)) & " hundred  " & "  " & Inwords(Right(nos, 2))
   End If
    Case 1001 To 9999
        Istr = Inwords(Left(nos, 1)) & " Thousand " & Inwords(Right(nos, 3))
    Case 10000 To 99999
        Istr = Inwords(Mid(nos, 1, 2)) & " Thousand " & Inwords(Right(nos, 3))
    Case 100000 To 999999
        Istr = Inwords(Left(nos, 1)) & " Lakh " & Inwords(Right(nos, 5))
    Case 1000000 To 9999999
        Istr = Inwords(Left(nos, 2)) & " Lakh " & Inwords(Right(nos, 5))
    Case 10000000 To 99999999
        Istr = Inwords(Left(nos, 1)) & " Crore " & Inwords(Right(nos, 7))
    Case 100000000 To 999999999
        Istr = Inwords(Left(nos, 2)) & " Crore " & Inwords(Right(nos, 7))
    Case 100
        Istr = Inwords(Left(nos, 1)) & "Hundred  "
    Case 1000
         Istr = Inwords(Left(nos, 1)) & "Thousand"
    Case 100000
         Istr = Inwords(Left(nos, 1)) & "Lakh"
    Case 10000000
           Istr = Inwords(Left(nos, 1)) & "Crore"
End Select
Inwords = Istr
End Function


private Function Piase(ByVal pi As String) As String
Dim Istr As String
Dim nos
nos = pi
Select Case nos
    Case 0 To 15
        Istr = Choose(nos + 1, "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen")
    Case 16 To 19
        Istr = Inwords(Right(nos, 1)) & "teen"
    Case 20, 30, 40, 50, 60, 70, 80, 90
        Istr = Choose(nos / 10, "RAVI", "Twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninty")
    Case 21 To 99
        Istr = Inwords(Left(nos, 1) & 0) & Inwords(Right(nos, 1))
    End Select
Piase = Istr
End Function


Public Function CMoney(ByVal strr As String) As String
Dim rs
rs = (Right(strr, (Len(strr) - InStr(1, strr, "."))))
If Val(strr) = 0 Then
Exit Function
End If
 If InStr(1, strr, ".") <> 0 Then
    If Len(Right(strr, (Len(strr) - InStr(1, strr, ".")))) = 1 Then
            If Val(Mid(strr, 1, InStr(1, strr, "."))) = 0 Then
                   CMoney= Piase(rs * 10) & " Paise Only"
             Else
                   CMoney= Inwords(Left(strr, InStr(1, strr, ".") - 1)) & " Rupees  " & " And " & Piase(rs * 10) & " Paise Only"
              End If
    Else
            If Val(Mid(strr, 1, InStr(1, strr, "."))) = 0 Then
                       CMoney= Piase(Right(strr, (Len(strr) - InStr(1, strr, ".")))) & " Piase Only"
            Else
             CMoney= Inwords(Left(strr, InStr(1, strr, ".") - 1)) & " Rupees  " & " And " & Piase(Right(strr, (Len(strr) - InStr(1, strr, ".")))) & " Paise Only"
            End If
    End If
Else
    CMoney = Inwords(strr) & " Rupees  Only"
End If
End Function


Download this snippet    Add to My Saved Code

------used recursive function------ Comments

No comments have been posted about ------used recursive function------. Why not be the first to post a comment about ------used recursive function------.

Post your comment

Subject:
Message:
0/1000 characters