Code that will help you to convert figures into words
Code that will help you to convert figures into words
API Declarations
Dim ty(9)
Dim hun(5)
Rate Code that will help you to convert figures into words
(2(2 Vote))
Private Sub Command1_Click()
Dim nosplit(5)
Dim resplit(5)
Dim p As Integer
Dim nos, str1 As String
'This Following statement is used for specify the input length 9
nos = Trim(inno.Text)
p = InStr(1, nos, ".", 1)
pais = Mid(nos, p + 1, 2)
If Len(pais) = 1 Then
pais = pais + "0"
End If
If p > 0 Then
nos = Mid(nos, 1, p - 1)
End If
nos = String((9 - Len(nos)), "0") + nos
'split statement
nosplit(1) = Val(Mid(nos, 1, 2))
nosplit(2) = Val(Mid(nos, 3, 2))
nosplit(3) = Val(Mid(nos, 5, 2))
nosplit(4) = Val(Mid(nos, 7, 1))
nosplit(5) = Val(Mid(nos, 8, 2))
For i = 1 To 5
spli = nosplit(i)
If spli > 0 And spli < 20 Then
resplit(i) = Trim(one(spli)) + " "
End If
If spli > 19 Then
spli1 = Val(Mid(Trim(spli), 1, 1))
spli2 = Val(Mid(Trim(spli), 2, 1))
resplit(i) = Trim(ty(spli1)) + " "
If spli2 > 0 Then
resplit(i) = Trim(ty(spli1)) + " " + Trim(one(spli2)) + " "
End If
End If
If Not resplit(i) = "" Then
result = result & resplit(i) & hun(i)
End If
Next i
'paise calculations
If p > 0 Then
If pais > 0 And pais < 20 Then
PAISE = Trim(one(pais)) + " "
End If
If pais > 19 Then
pais1 = Val(Mid(Trim(pais), 1, 1))
pais2 = Val(Mid(Trim(pais), 2, 1))
PAISE = Trim(ty(pais1)) + " "
If pais2 > 0 Then
PAISE = Trim(ty(pais1)) + " " + Trim(one(pais2))
End If
End If
Else
PAISE = ""
End If
If p > 0 Then
Label2.Caption = result + " Rupees " + PAISE + " Paise"
Else
Label2.Caption = "Rupees " + result
End If
'Command1.Caption = result + paise
End Sub
Private Sub Form_Load()
one(1) = "One "
one(2) = " Two "
one(3) = " Three "
one(4) = " Four "
one(5) = " Five "
one(6) = " Six "
one(7) = " Seven "
one(8) = " Eight "
one(9) = " Nine "
one(10) = " Ten "
one(11) = "Eleven "
one(12) = "Twelve "
one(13) = "Thirteen "
one(14) = "Fourteen "
one(15) = "Fifteen "
one(16) = "Sixteen "
one(17) = "Seventeen "
one(18) = "Eighteen "
one(19) = "Ninteen "
ty(1) = ""
ty(2) = "Twenty "
ty(3) = "Thirty "
ty(4) = "Fourty "
ty(5) = "Fifty "
ty(6) = "Sixty "
ty(7) = "Seventy "
ty(8) = "Eighty "
ty(9) = "Ninety "
hun(1) = "Crore(s) "
hun(2) = "Lakh(s) "
hun(3) = "Thousand "
hun(4) = "Hundred and "
End Sub
Private Sub inno_KeyPress(KeyAscii As Integer)
'If Len(inno.Text) > 9 Then
'KeyAscii = 0
'End If
If KeyAscii >= 46 And KeyAscii <= 58 Or KeyAscii = 8 Then
Else
KeyAscii = 0
End If
End Sub
Code that will help you to convert figures into words Comments
No comments yet — be the first to post one!
Post a Comment