by Raghuraja. C (21 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 17th February 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This function will allow only Currency in text boxed
Private Sub txtCurency_KeyPress(KeyAscii As Integer)
KeyAscii = fnOnlyOrderCurrency(txtCurency, KeyAscii)
End Sub
'==================================
Public Function fnOnlyCurrency(objText As Object, intKP As Integer) As Integer
On Error GoTo LOCALERRORHANDLER
'To allow only Currency values 99999999.00
fnOnlyCurrency = intKP
If Len(objText.Text) > 12 Then
fnOnlyCurrency = 0
End If
If intKP = 8 Then
Exit Function
End If
If InStr(1, objText.Text, ".") <> 0 And intKP = 46 Then
fnOnlyCurrency = 0
ElseIf InStr(1, objText.Text, ".") <> 0 And (intKP > 47 And intKP < 58) Then
If Len(Mid(objText.Text, (InStr(1, objText.Text, ".") + 1))) >= 4 And objText.SelStart >= InStr(1, objText.Text, ".") Then
fnOnlyCurrency = 0
End If
Else
If (intKP > 47 And intKP < 58) Or intKP = 8 Or intKP = 46 Or intKP = 13 Then
Else
fnOnlyCurrency = 0
End If
End If
Exit Function
LOCALERRORHANDLER:
fnOnlyCurrency = 0
End Function