View Single Post
  #6 (permalink)  
Old January 17th, 2006, 03:44 AM
civa civa is offline
Authorized User
 
Join Date: Jan 2005
Location: , , .
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hello alistar
 I thank for your kind response, but your help is required once again

1. the out put for point one should be
  12.34 is Tewleve and paise thirty four
  1234.56 is one thousand two hundred thirthy four and paise fifty six
  123456.78 is one lakh twenty three thousand four hundered fifty six
               and paise seventy eight

2. currency number does not put any symbols, letters and non symbols
3. numbers are always followed by decimals

i have changed my code little bit since select case statement is not giving any value my new code is like below

Function GetWords(ByVal Amt As Currency) As String
Dim S(27) As String
Dim MW(7) As String
Dim Words As String
Dim AndFlg As Boolean
Dim Mno As String
Dim Pno As String
Dim J As Integer
    S(1) = " One"
    S(2) = " Two"
    S(3) = " Three"
    S(4) = " Four"
    S(5) = " Five"
    S(6) = " Six"
    S(7) = " Seven"
    S(8) = " Eight"
    S(9) = " Nine"
    S(10) = " Ten"
    S(11) = " Eleven"
    S(12) = " Twelve"
    S(13) = " Thirteen"
    S(14) = " Fourteen"
    S(15) = " Fifteen"
    S(16) = " Sixteen"
    S(17) = " Seventeen"
    S(18) = " Eighteen"
    S(19) = " Nineteen"
    S(20) = " Twenty"
    S(21) = " Thirty"
    S(22) = " Forty"
    S(23) = " Fifty"
    S(24) = " Sixty"
    S(25) = " Seventy"
    S(26) = " Eighty"
    S(27) = " Ninety"

    MW(1) = " Hundred"
    MW(2) = " Crore"
    MW(3) = " Lakhs"
    MW(4) = " Thousand"
    MW(5) = " Hundred"
    MW(6) = ""
    MW(7) = " Paise"
    Words = ""


    Pno = Str(Int(Amt)) + Mid(Str(Amt), Len(Str(Amt)) - 1, 2)

    AndFlg = False
    For J = 7 To 1 Step -1

    Mno = Val(IIf(J = 1 Or J = 5, Mid(Pno, Len(Pno), 1), Mid(Pno, Len(Pno) - 1, 2)))

       If Mno = 0 Then
       ElseIf Mno <= 20 Then
       Words = S(Mno) + MW(J) + Words
       Else
       Words = S(18 + Int(Mno / 10)) + IIf(Mno Mod 10 > 0, S(Mno Mod 10), "") + MW(J) + Words
       End If
       If Not AndFlg And Words <> "" And (Amt > 99 Or (Amt - Int(Amt) > 0 And Amt > 0.99)) Then
            If (Amt Mod 100) <> 0 Then
       Words = " and" + Words
                AndFlg = True
            End If
        End If
        Pno = Mid(Pno, 1, Len(Pno) - IIf(J = 1 Or J = 5, 1, 2))

        If Len(Trim(Pno)) = 0 Then
        GetWords = Words + " Only"
        Exit Function
        End If
        Next

End Function


 with this above code iam able to get all values correct but the problem is doing tens & fractions

the examples with above code are as shown below

1.00 is One One Paise Only
1.15 is One and Fifteen Paise Only
12.34 Tewleve and paise thirty four
12.00 is Twelve Twelve Paise Only
1234.56 is One Thousand Two Hundred Thirty Four and Fifty Six Paise
           Only
1234.00 is One Thousand Two Hundred Thirty Four and Thirty Four Paise
           Only
123456.78 is One Lakhs Twenty Three Thousand Four Hundred Fifty Six
             and Seventy Eight Paise Only
123456.00 is One Lakhs Twenty Three Thousand Four Hundred Fifty Six
              and Fifty Six Paise Only

help required on this

Reply With Quote