- Home
·
- Math/Dates
·
- Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun
Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun
Convert Digit e.g."4321" Into Words i.e."Four Thousand Three Hundred Twenty One Only" with this function. Very useful in making Invoices,
API Declarations
Private Counter_I, Decimals, Digits
Private Temp As Long
Private AmtDigit(4) As Long
Private AmtText(4) As String
Private AmtInWords As String
Rate Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun
(2(2 Vote))
'41, shukrawar ward,
'5 Kandil, Rath Lane
'Malegaon [Nashik]
'Maharashtra [INDIA]
Private Sub Set_Values()
AmtDigit(1) = 10000000
AmtDigit(2) = 100000
AmtDigit(3) = 1000
AmtDigit(4) = 100
AmtText(1) = "Crore "
AmtText(2) = "Lakh "
AmtText(3) = "Thousand "
AmtText(4) = "Hundered "
End Sub
'PASS THE NUMBER FOR THE DESIRED STRING TO THIS FUNCTION
'e.g. txtAmountInWords = CAmountInWords(txtAmount.text)
Public Function CAmountInWords(ByVal Amount As Long) As String
Set_Values ' Convert Digit Amount In Word Format
AmtInWords = ""
For Counter_I = 1 To 4
If Not Amount = 0 Then
Temp = Int(Amount / AmtDigit(Counter_I))
If Temp > 0 Then
Get_Text
AmtInWords = AmtInWords + AmtText(Counter_I)
End If
Amount = Amount Mod AmtDigit(Counter_I)
End If
Next Counter_I
Temp = Amount
If Not Amount = 0 Then Get_Text
CAmountInWords = AmtInWords & "Only"
End Function
Private Sub Get_Text()
If Temp >= 20 Then
Decimals = Int(Temp / 10)
Digits = Temp Mod 10
Else
Decimals = 0
Digits = Temp
End If
Select Case Decimals
Case 0: AmtInWords = AmtInWords
Case 2: AmtInWords = AmtInWords + "Twenty "
Case 3: AmtInWords = AmtInWords + "Thirty "
Case 4: AmtInWords = AmtInWords + "Fourty "
Case 5: AmtInWords = AmtInWords + "Fifty "
Case 6: AmtInWords = AmtInWords + "Sixty "
Case 7: AmtInWords = AmtInWords + "Seventy "
Case 8: AmtInWords = AmtInWords + "Eighty "
Case 9: AmtInWords = AmtInWords + "Ninety "
End Select
Select Case Digits
Case 0: AmtInWords = AmtInWords
Case 1: AmtInWords = AmtInWords + "One "
Case 2: AmtInWords = AmtInWords + "Two "
Case 3: AmtInWords = AmtInWords + "Three "
Case 4: AmtInWords = AmtInWords + "Four "
Case 5: AmtInWords = AmtInWords + "Five "
Case 6: AmtInWords = AmtInWords + "Six "
Case 7: AmtInWords = AmtInWords + "Seven "
Case 8: AmtInWords = AmtInWords + "Eight "
Case 9: AmtInWords = AmtInWords + "Nine "
Case 10: AmtInWords = AmtInWords + "Ten "
Case 11: AmtInWords = AmtInWords + "Eleven "
Case 12: AmtInWords = AmtInWords + "Twelve "
Case 13: AmtInWords = AmtInWords + "Thirteen "
Case 14: AmtInWords = AmtInWords + "Fourteen "
Case 15: AmtInWords = AmtInWords + "Fifteen "
Case 16: AmtInWords = AmtInWords + "Sixteen "
Case 17: AmtInWords = AmtInWords + "Seventeen "
Case 18: AmtInWords = AmtInWords + "Eighteen "
Case 19: AmtInWords = AmtInWords + "Nineteen "
Case 20: AmtInWords = AmtInWords + "Twenty "
End Select
End Sub
Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun Comments
No comments yet — be the first to post one!
Post a Comment