0% found this document useful (0 votes)
57 views2 pages

Currency to Words in VBA

This function takes a numeric amount as input and returns a string representing the amount in words in Hindi. It breaks down the amount into crores, lakhs, thousands, hundreds, and paise sections. Strings for individual numbers from 1-19 and tens places from 20-90 are stored in arrays. The function uses substring operations and conversions to integer values to extract each section of the amount, look up the corresponding word in the arrays, and concatenate it into the output string along with place value descriptors.

Uploaded by

rajkumaress
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

Currency to Words in VBA

This function takes a numeric amount as input and returns a string representing the amount in words in Hindi. It breaks down the amount into crores, lakhs, thousands, hundreds, and paise sections. Strings for individual numbers from 1-19 and tens places from 20-90 are stored in arrays. The function uses substring operations and conversions to integer values to extract each section of the amount, look up the corresponding word in the arrays, and concatenate it into the output string along with place value descriptors.

Uploaded by

rajkumaress
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Function Rup(amt As Variant) As Variant

Dim FIGURE As Variant


Dim LENFIG As Integer
Dim i As Integer
Dim WORDs(19) As String
Dim tens(9) As String
WORDs(1) = "One"
WORDs(2) = "Two"
WORDs(3) = "Three"
WORDs(4) = "Four"
WORDs(5) = "Five"
WORDs(6) = "Six"
WORDs(7) = "Seven"
WORDs(8) = "Eight"
WORDs(9) = "Nine"
WORDs(10) = "Ten"
WORDs(11) = "Eleven"
WORDs(12) = "Twelve"
WORDs(13) = "Thirteen"
WORDs(14) = "Fourteen"
WORDs(15) = "Fifteen"
WORDs(16) = "Sixteen"
WORDs(17) = "Seventeen"
WORDs(18) = "Eighteen"
WORDs(19) = "Nineteen"
tens(2) = "Twenty"
tens(3) = "Thirty"
tens(4) = "Fourty"
tens(5) = "Fifty"
tens(6) = "Sixty"
tens(7) = "Seventy"
tens(8) = "Eighty"
tens(9) = "Ninety"
FIGURE = amt
FIGURE = Format(FIGURE, "FIXED")
FIGLEN = Len(FIGURE)
If FIGLEN < 12 Then
FIGURE = Space(12 - FIGLEN) & FIGURE
End If
If Val(Left(FIGURE, 9)) > 1 Then
Rup = "Rupees "
ElseIf Val(Left(FIGURE, 9)) = 1 Then
Rup = "Rupee "
End If
For i = 1 To 3
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
Rup = Rup & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
Rup = Rup & tens(Val(Left(FIGURE, 1)))
Rup = Rup & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
If i = 1 And Val(Left(FIGURE, 2)) > 0 Then
Rup = Rup & " Crore "
ElseIf i = 2 And Val(Left(FIGURE, 2)) > 0 Then
Rup = Rup & " Lakh "
ElseIf i = 3 And Val(Left(FIGURE, 2)) > 0 Then
Rup = Rup & " Thousand "
End If
FIGURE = Mid(FIGURE, 3)
Next i
If Val(Left(FIGURE, 1)) > 0 Then
Rup = Rup & WORDs(Val(Left(FIGURE, 1))) + " Hundred "
End If
FIGURE = Mid(FIGURE, 2)
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
Rup = Rup & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
Rup = Rup & tens(Val(Left(FIGURE, 1)))
Rup = Rup & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
FIGURE = Mid(FIGURE, 4)
If Val(FIGURE) > 0 Then
Rup = Rup & " Paise "
If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
Rup = Rup & WORDs(Val(Left(FIGURE, 2)))
ElseIf Val(Left(FIGURE, 2)) > 19 Then
Rup = Rup & tens(Val(Left(FIGURE, 1)))
Rup = Rup & WORDs(Val(Right(Left(FIGURE, 2), 1)))
End If
End If
FIGURE = amt
FIGURE = Format(FIGURE, "FIXED")
If Val(FIGURE) > 0 Then
Rup = Rup & " Only "
End If
End Function

You might also like