VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun

by Sandeep Jakhotya (2 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 13th September 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



'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


Download this snippet    Add to My Saved Code

Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun Comments

No comments have been posted about Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun. Why not be the first to post a comment about Convert Digit e.g.4321 Into Words i.e.Four Thousand Three Hundred Twenty One Only with this fun.

Post your comment

Subject:
Message:
0/1000 characters