VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



To Convert Amount in Figures To Words

by Ratish Pillai (1 Submission)
Category: Math/Dates
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 18th November 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

To Convert Amount in Figures To Words

API Declarations



Dim str As String
Dim str1 As String


Rate To Convert Amount in Figures To Words



Dim u, ps As Integer
Dim t As Integer
Dim h As Integer
Dim tt As Double
Dim l As Double
Dim tl As Double
str1 = ""
alt = InStr(1, i, ".", vbTextCompare)
nnn = Len(i) - alt
ps = Mid(i, alt + 1, nnn)
If alt <> 0 Then
If ps <> 0 Then
 If ps > 20 Then
    ps2 = Int(ps Mod 10)
    ps1 = Int(ps - ps2)
    rsinwords Int(ps2)
    str1 = str & str1
    rsinwords Int(ps1)
    str1 = " And Paise" & str & str1
 Else
    rsinwords Int(ps)
    str1 = " And Paise" & str & str1
 End If
End If
End If

If Int(i) = 0 Then
str1 = " Nil"
GoTo r:
End If

u = Int(i) Mod 100
If u <> 0 Then
 If u > 20 Then
    u2 = Int(u Mod 10)
    u1 = Int(u - u2)
    rsinwords Int(u2)
    str1 = str & str1
    rsinwords Int(u1)
    str1 = str & str1
 Else
    rsinwords Int(u)
    str1 = str & str1
    End If
Else
'str1 = " Nil" & str1
End If


h1 = Int(i Mod 1000)
h1 = Int(h1 / 100)
If h1 <> 0 Then
rsinwords Int(h1)
str1 = str & " Hundred" & str1
End If

tt = Int(i Mod 100000)
tt = Int(tt / 1000)
If tt <> 0 Then
 If tt > 20 Then
    tt2 = Int(tt Mod 10)
    tt1 = Int(tt - tt2)
    rsinwords Int(tt2)
    str1 = str & " Thousand" & str1
    rsinwords Int(tt1)
    str1 = str & str1
Else
    rsinwords Int(tt)
    str1 = str & " Thousand" & str1
End If
End If

tl = Int(i Mod 10000000)
tl = Int(tl / 100000)
If tl <> 0 Then
 If tl > 20 Then
    tl2 = Int(tl Mod 10)
    tl1 = Int(tl - tl2)
    rsinwords Int(tl2)
    str1 = str & " Lakh" & str1
    rsinwords Int(tl1)
    str1 = str & str1
Else
    rsinwords Int(tl)
    str1 = str & " Lakh" & str1
End If
End If

tc = Int(i Mod 1000000000)
tc = Int(tc / 10000000)
If tc <> 0 Then
 If tc > 20 Then
    tc2 = Int(tc Mod 10)
    tc1 = Int(tc - tc2)
    rsinwords Int(tc2)
    str1 = str & " Crore" & str1
    rsinwords Int(tc1)
    str1 = str & str1
Else
    rsinwords Int(tc)
    str1 = str & " Crore" & str1
End If
End If

r:
MsgBox "Rupees" & str1 & " Only"
str1 = ""
str = ""
End Sub

Public Function rsinwords(rs As Integer)
Select Case (rs)
Case 1
    str = " One"
Case 2
    str = " Two"
Case 3
    str = " Three"
Case 4
    str = " Four"
Case 5
    str = " Five"
Case 6
    str = " Six"
Case 7
    str = " Seven"
Case 8
    str = " Eight"
Case 9
    str = " Nine"
Case 10
    str = " Ten"
Case 11
    str = " Eleven"
Case 12
    str = " Twelve"
Case 13
    str = " Thirteen"
Case 14
    str = " Fourteen"
Case 15
    str = " Fifteen"
Case 16
    str = " Sixteen"
Case 17
    str = " Seventeen"
Case 18
    str = " Eighteen"
Case 19
    str = " Nineteen"
Case 20
    str = " Twenty"
Case 30
    str = " Thirty"
Case 40
    str = " Forty"
Case 50
    str = " Fifty"
Case 60
    str = " Sixty"
Case 70
    str = " Seventy"
Case 80
    str = " Eighty"
Case 90
    str = " Ninety"
End Select
End Function


Download this snippet    Add to My Saved Code

To Convert Amount in Figures To Words Comments

No comments have been posted about To Convert Amount in Figures To Words. Why not be the first to post a comment about To Convert Amount in Figures To Words.

Post your comment

Subject:
Message:
0/1000 characters