Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Convert an Amount into words (ltd. up to 100 cores...
Author:
Umesh K Suryawanshi
E-mail:
Click to e-mail author
Submitted:
2/1/2002
Version:
VB5
Compatibility:
VB5, VB6
Category:
Mathematics
Views:
12863
Convert an Amount into words (ltd. up to 100 cores )
Declarations:
'Put one command button, label, textbox on form & paste the following code.
Code:
' May not work propery with amount with digits Private Sub Command1_Click() If Text1.Text <> "" Then Label1.Caption = FWords(Text1.Text) & Space(1) & "Only" Else MsgBox "Please Enter Amount" Text1.SetFocus End If End Sub Private Sub Form_Load() Label1.AutoSize = True Text1.Text = "" End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Dim st As String Dim num As Integer KeyAscii = Asc(UCase(Chr(KeyAscii))) st = "ABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_-+=./?<>;'" num = InStr(st, Chr(KeyAscii)) If num > 0 Then KeyAscii = 0 End If End Sub Private Function FWords(Fig As String) pos = InStr(CStr(Fig), ".") If pos = 0 Then strfig = Trim(Str(Fig)) + ".00" Else strfig = CStr(Fig) End If strlen = Len(strfig) word = "" Select Case strlen Case 4 word = strlen4(strfig) Case 5 word = strlen5(strfig) Case 6 word = strlen6(strfig) Case 7 word = strlen7(strfig) Case 8 word = strlen8(strfig) Case 9 word = strlen9(strfig) Case 10 word = strlen10(strfig) Case 11 word = strlen11(strfig) Case 12 word = strlen12(strfig) Case 13 word = strlen13(strfig) End Select FWords = word End Function Function strlen4(strfig) word = unit(strfig, 1, 1) If word <> "" Then If Mid(strfig, 1, 1) = "1" Then word = word + "Rupee " Else word = word + "Rupees " End If End If wordpp = paise(strfig, 3, 1) word = word + wordpp strlen4 = word End Function Private Function strlen5(strfig) If Mid(strfig, 1, 1) = "1" Then tempword = teens(strfig, 2, 1) word = tempword + "Rupees " Else tempword = tens(strfig, 1, 1) word = tempword + unit(strfig, 2, 1) + "Rupees " End If wordpp = paise(strfig, 4, 1) word = word + wordpp strlen5 = word End Function Private Function strlen6(strfig) word = unit(strfig, 1, 1) If Mid(strfig, 2, 2) = "00" Then word = word + "Hundred " Else word = word + "Hundred and " End If If Mid(strfig, 2, 1) = "1" Then tempword = teens(strfig, 3, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 2, 1) word = word + tempword + unit(strfig, 3, 1) + "Rupees " End If wordpp = paise(strfig, 5, 1) word = word + wordpp strlen6 = word End Function Private Function strlen7(strfig) word = unit(strfig, 1, 1) + "Thousand " If Mid(strfig, 2, 1) <> "0" Then tword = unit(strfig, 2, 1) If Mid(strfig, 3, 2) = "00" Then word = word + tword + "Hundred " Else word = word + tword + "Hundred and " End If End If If Mid(strfig, 3, 1) = "1" Then tempword = teens(strfig, 4, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 3, 1) word = word + tempword + unit(strfig, 4, 1) + "Rupees " End If wordpp = paise(strfig, 6, 1) word = word + wordpp strlen7 = word End Function Private Function strlen8(strfig) If Mid(strfig, 1, 1) = "1" Then tee = teens(strfig, 2, 1) word = tee + "Thousand " Else tee = tens(strfig, 1, 1) word = tee + unit(strfig, 2, 1) + "Thousand " End If If Mid(strfig, 3, 1) <> "0" Then tword = unit(strfig, 3, 1) If Mid(strfig, 4, 2) = "00" Then word = word + tword + "Hundred " Else word = word + tword + "Hundred and " End If End If If Mid(strfig, 4, 1) = "1" Then tempword = teens(strfig, 5, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 4, 1) word = word + tempword + unit(strfig, 5, 1) + "Rupees " End If wordpp = paise(strfig, 7, 1) word = word + wordpp strlen8 = word End Function Private Function strlen9(strfig) wlac = unit(strfig, 1, 1) If Mid(strfig, 1, 1) = "1" Then word = wlac + "Lac " Else word = wlac + "Lacs " End If If Mid(strfig, 2, 1) = "1" Then tee = teens(strfig, 3, 1) word = word + tee + "Thousand " Else tee = tens(strfig, 2, 1) If Mid(strfig, 2, 2) <> "00" Then word = word + tee + unit(strfig, 3, 1) + "Thousand " End If End If If Mid(strfig, 4, 1) <> "0" Then tword = unit(strfig, 4, 1) If Mid(strfig, 5, 2) = "00" Then word = word + tword + "Hundred " Else word = word + tword + "Hundred and " End If End If If Mid(strfig, 5, 1) = "1" Then tempword = teens(strfig, 6, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 5, 1) word = word + tempword + unit(strfig, 6, 1) + "Rupees " End If wordpp = paise(strfig, 8, 1) word = word + wordpp strlen9 = word End Function Private Function strlen10(strfig) If Mid(strfig, 1, 1) = "1" Then tee = teens(strfig, 2, 1) word = tee + "Lacs " Else tee = tens(strfig, 1, 1) word = tee + unit(strfig, 2, 1) + "Lacs " End If If Mid(strfig, 3, 1) = "1" Then tee = teens(strfig, 4, 1) word = word + tee + "Thousand " Else tee = tens(strfig, 3, 1) If Mid(strfig, 3, 2) <> "00" Then word = word + tee + unit(strfig, 4, 1) + "Thousand " End If End If If Mid(strfig, 5, 1) <> "0" Then tword = unit(strfig, 5, 1) If Mid(strfig, 6, 2) = "00" Then word = word + tword + "Hundred " Else word = word + tword + "Hundred and " End If End If If Mid(strfig, 6, 1) = "1" Then tempword = teens(strfig, 7, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 6, 1) word = word + tempword + unit(strfig, 7, 1) + "Rupees " End If wordpp = paise(strfig, 9, 1) word = word + wordpp strlen10 = word End Function Private Function strlen11(strfig) word = unit(strfig, 1, 1) If Mid(strfig, 1, 1) = "1" Then word = word + "Crore " Else word = word + "Crores " End If If Mid(strfig, 2, 2) <> "00" Then If Mid(strfig, 2, 1) = "1" Then tee = teens(strfig, 3, 1) word = word + tee + "Lacs " Else tee = tens(strfig, 2, 1) word = word + tee + unit(strfig, 3, 1) + "Lacs " End If End If If Mid(strfig, 4, 1) = "1" Then tee = teens(strfig, 5, 1) word = word + tee + "Thousand " Else tee = tens(strfig, 4, 1) If Mid(strfig, 4, 2) <> "00" Then word = word + tee + unit(strfig, 5, 1) + "Thousand " End If End If If Mid(strfig, 6, 1) <> "0" Then tword = unit(strfig, 7, 1) If Mid(strfig, 7, 2) = "00" Then word = word + tword + "Hundred " Else word = word + tword + "Hundred and " End If End If If Mid(strfig, 7, 1) = "1" Then tempword = teens(strfig, 8, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 7, 1) word = word + tempword + unit(strfig, 8, 1) + "Rupees " End If wordpp = paise(strfig, 10, 1) word = word + wordpp strlen11 = word End Function Private Function strlen12(strfig) If Mid(strfig, 1, 1) = "1" Then tee = teens(strfig, 2, 1) word = tee + "Crores " Else tee = tens(strfig, 1, 1) word = tee + unit(strfig, 2, 1) + "Crores " End If If Mid(strfig, 3, 2) <> "00" Then If Mid(strfig, 3, 1) = "1" Then tee = teens(strfig, 4, 1) word = word + tee + "Lacs " Else tee = tens(strfig, 3, 1) word = word + tee + unit(strfig, 4, 1) + "Lacs " End If End If If Mid(strfig, 5, 1) = "1" Then tee = teens(strfig, 6, 1) word = word + tee + "Thousand " Else tee = tens(strfig, 5, 1) If Mid(strfig, 5, 2) <> "00" Then word = word + tee + unit(strfig, 6, 1) + "Thousand " End If End If If Mid(strfig, 7, 1) <> "0" Then tword = unit(strfig, 8, 1) If Mid(strfig, 8, 2) = "00" Then word = word + tword + "Hundred " Else word = word + tword + "Hundred and " End If End If If Mid(strfig, 8, 1) = "1" Then tempword = teens(strfig, 9, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 8, 1) word = word + tempword + unit(strfig, 9, 1) + "Rupees " End If wordpp = paise(strfig, 11, 1) word = word + wordpp strlen12 = word End Function Private Function strlen13(strfig) word = unit(strfig, 1, 1) If Mid(strfig, 2, 2) = "00" Then word = word + "Hundred Crore " Else word = word + "Hundred and " If Mid(strfig, 2, 1) = "1" Then tee = teens(strfig, 3, 1) word = word + tee + "Crores " Else tee = tens(strfig, 2, 1) word = word + tee + unit(strfig, 3, 1) + "Crores " End If End If If Mid(strfig, 4, 2) <> "00" Then If Mid(strfig, 4, 1) = "1" Then tee = teens(strfig, 5, 1) word = word + tee + "Lacs " Else tee = tens(strfig, 4, 1) word = word + tee + unit(strfig, 5, 1) + "Lacs " End If End If If Mid(strfig, 6, 1) = "1" Then tee = teens(strfig, 7, 1) word = word + tee + "Thousand " Else tee = tens(strfig, 6, 1) If Mid(strfig, 6, 2) <> "00" Then word = word + tee + unit(strfig, 7, 1) + "Thousand " End If End If If Mid(strfig, 8, 1) <> "0" Then tword = unit(strfig, 9, 1) If Mid(strfig, 9, 2) = "00" Then word = word + tword + "Hundred " Else word = word + tword + "Hundred and " End If End If If Mid(strfig, 9, 1) = "1" Then tempword = teens(strfig, 10, 1) word = word + tempword + "Rupees " Else tempword = tens(strfig, 9, 1) word = word + tempword + unit(strfig, 10, 1) + "Rupees " End If wordpp = paise(strfig, 12, 1) word = word + wordpp strlen13 = word End Function Private Function unit(strfig, Char, Count) word1 = "" unt = Mid(strfig, Char, Count) Select Case unt Case "0" word1 = "" Case "1" word1 = "One " Case "2" word1 = "Two " Case "3" word1 = "Three " Case "4" word1 = "Four " Case "5" word1 = "Five " Case "6" word1 = "Six " Case "7" word1 = "Seven " Case "8" word1 = "Eight " Case "9" word1 = "Nine " End Select unit = word1 End Function Private Function tens(strfig, Char, Count) wordten = "" y = Mid(strfig, Char, Count) Select Case y Case "2" wordten = "Twenty " Case "3" wordten = "Thrirty " Case "4" wordten = "Fourty " Case "5" wordten = "Fifty " Case "6" wordten = "Sixty " Case "7" wordten = "Seventy " Case "8" wordten = "Eighty " Case "9" wordten = "Ninety " End Select tens = wordten End Function Private Function teens(strfig, Char, Count) y = Mid(strfig, Char, Count) Select Case y Case "0" wordtee = "Ten " Case "1" wordtee = "Eleven " Case "2" wordtee = "Twelve " Case "3" wordtee = "Thirteen " Case "4" wordtee = "Fourteen " Case "5" wordtee = "Fifteen " Case "6" wordtee = "Sixteen " Case "7" wordtee = "Seventeen " Case "8" wordtee = "Eighteen " Case "9" wordtee = "Nineteen " End Select teens = wordtee End Function Private Function paise(strfig, Char, Count) wordp = "" pse = Mid(strfig, Char, Count) Select Case pse Case "0" ' nothing here Case "1" x = Mid(strfig, Char + 1, Count) Select Case x Case "0" wordp = "Ten Paise" Case "1" wordp = "Eleven Paise" Case "2" wordp = "Twelve Paise" Case "3" wordp = "Thirteen Paise" Case "4" wordp = "Fourteen Paise" Case "5" wordp = "Fifteen Paise" Case "6" wordp = "Sixteen Paise" Case "7" wordp = "Seventeen Paise" Case "8" wordp = "Eighteen Paise" Case "9" wordp = "Nineteen Paise" End Select Case "2" wordp = "Twenty " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If Case "3" wordp = "Thrirty " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If Case "4" wordp = "Fourty " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If Case Mid(strfig, Char, Count) = "5" wordp = "Fifty " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If Case Mid(strfig, Char, Count) = "6" wordp = "Sixty " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If Case Mid(strfig, Char, Count) = "7" wordp = "Seventy " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If Case Mid(strfig, Char, Count) = "8" wordp = "Eighty " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If Case Mid(strfig, Char, Count) = "9" wordp = "Ninety " If Mid(strfig, Char + 1, Count) = "0" Then wordp = wordp + "Paise" End If End Select y = Mid(strfig, Char + 1, Count) Select Case y Case "1" If Mid(strfig, Char, Count) = "0" Then wordp = wordp + "One paisa" Else wordp = wordp + "One Paise" End If Case "2" wordp = wordp + "Two Paise " Case "3" wordp = wordp + "Three Paise " Case "4" wordp = wordp + "Four Paise " Case "5" wordp = wordp + "Five Paise " Case "6" wordp = wordp + "Six Paise " Case "7" wordp = wordp + "Seven Paise " Case "8" wordp = wordp + "Eight Paise " Case "9" wordp = wordp + "Nine Paise " End Select paise = wordp End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2024 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement