by Nirene (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 31st January 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This function validates numbers entered in the text box and restricts 2 decimal places,and this is called in the keypress event of the text
Dim Deciprs As Boolean
Dim Ctr As Integer
Dim Decipos As Integer
Decipos = InStr(Strinfo, ".")
If Decipos Then
Deciprs = True
Else
Deciprs = False
End If
Select Case Key
Case vbKey0 To vbKey9
If Deciprs = True Then
Ctr = Len(Mid(Strinfo, Decipos + 1, Len(Strinfo) - Decipos + 1))
If Ctr = 2 Then
Txtnumdeci = 0
Else
Txtnumdeci = Key
End If
Else
Txtnumdeci = Key
End If
Case vbKeyBack
Txtnumdeci = Key
Case vbKeyDecimal, Asc(".")
If Deciprs = True Then
Txtnumdeci = 0
Else
Txtnumdeci = Key
End If
Case vbKeyReturn
SendKeys "{TAB}"
Case Else
Txtnumdeci = 0
End Select
End Function
No comments have been posted about This function validates numbers entered in the text box and restricts 2 decimal places,and this is . Why not be the first to post a comment about This function validates numbers entered in the text box and restricts 2 decimal places,and this is .