You are on page 1of 3

Public Function Dim tempstr Dim tempnum Dim convstr Dim partlen Dim ptat As Dim digs As

spellnumber SpellNumber(Number As Double) As String As String As Double As String As Byte Byte Integer

convstr = "" ptat = InStr(1, CStr(Number), ".") If ptat = 0 Then tempnum = CStr(Number) Else tempnum = Mid(CStr(Number), 1, ptat) End If tempstr = Trim(CStr(tempnum)) While Not tempnum = 0 partlen = Len(tempstr) Select Case partlen Case Is >= 8 digs = CInt(Mid(tempstr, 1, partlen - 7)) convstr = diginwrd(digs) If digs > 1 Then convstr = convstr & "Crores " Else convstr = convstr & "Crore " End If tempstr = Right(tempstr, 7) Case Is >= 6 And partlen < 8 digs = CInt(Mid(tempstr, 1, partlen - 5)) convstr = convstr & diginwrd(digs) If digs >= 1 Then convstr = convstr & "Lakh " 'Else 'convstr = convstr & "Lakh " End If tempstr = Right(tempstr, 5) Case Is < 6 And partlen >= 4 digs = CInt(Mid(tempstr, 1, partlen - 3)) convstr = convstr + diginwrd(digs) If digs <> 0 Then convstr = convstr & "Thousand " End If tempstr = Right(tempstr, 3) Case Is <= 3 digs = CInt(tempstr) convstr = convstr + diginwrd(digs) tempstr = "0" End Select tempnum = CLng(tempstr) 'MsgBox Wend If ptat = 0 tempnum Else tempnum End If tempnum & convstr Then = 0 = Val(Right(CStr(Number), Len(CStr(Number)) - ptat + 1)) * 100 Page 1

spellnumber MsgBox convstr & tempnum convstr = "Rupees " & convstr If Not tempnum = 0 Then SpellNumber = convstr & "And " & diginwrd(tempnum) & "Paise Only" Else SpellNumber = convstr & "Only" End If End Function ' Public Function diginwrd(ByVal digsnum As Integer) As String Select Case digsnum Case 1 diginwrd = "One " Case 2 diginwrd = "Two " Case 3 diginwrd = "Three " Case 4 diginwrd = "Four " Case 5 diginwrd = "Five " Case 6 diginwrd = "Six " Case 7 diginwrd = "Seven " Case 8 diginwrd = "Eight " Case 9 diginwrd = "Nine " Case 10 diginwrd = "Ten " Case 11 diginwrd = "Eleven " Case 12 diginwrd = "Twelve " Case 13 diginwrd = "Thirteen " Case 14 diginwrd = "Fourteen " Case 15 diginwrd = "Fifteen " Case 16 diginwrd = "Sixteen " Case 17 diginwrd = "Seventeen " Case 18 diginwrd = "Eighteen " Case 19 diginwrd = "Nineteen " Case Is > 19 Dim dig As Integer Dim tdigword As String Dim thdig As String dig = CInt(Right(CStr(digsnum), 1)) If digsnum >= 100 Then thdig = Left(CStr(digsnum), 1) dig = CInt(Right(CStr(digsnum), 2)) Else dig = CInt(Right(CStr(digsnum), 1)) End If Select Case digsnum Case Is >= 100 Page 2

spellnumber tdigword = diginwrd(CInt(thdig)) & "Hundred " Case Is >= 90 And digsnum < 100 tdigword = "Ninety " Case Is >= 80 And digsnum < 90 tdigword = "Eighty " Case Is >= 70 And digsnum < 80 tdigword = "Seventy " Case Is >= 60 And digsnum < 70 tdigword = "Sixty " Case Is >= 50 And digsnum < 60 tdigword = "Fifty " Case Is >= 40 And digsnum < 50 tdigword = "Forty " Case Is >= 30 And digsnum < 40 tdigword = "Thirty " Case Is >= 20 And digsnum < 30 tdigword = "Twenty " End Select diginwrd = tdigword & diginwrd(dig) End Select End Function Function Tr(X) On Error Resume Next Tr = Int(X * 10) / 10 End Function

Page 3

You might also like