VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



It Validates the Data Entry in a Text Box.

by BharatMonga (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Thu 29th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

It Validates the Data Entry in a Text Box.

API Declarations


then in the tag property of Text box whatever
u have write the Data Type "Chr" or "Num"
Set the form's keypreview property=true.


Public Function DataEntryValidation(Key As Integer, Param As String) As Integer

'If BckSpace then allow

If Key = 8 Then DataEntryValidation = Key: Exit Function

'Enforce only Digits

Select Case Param

Case "Num"

If Key < Asc("0") Or Key > Asc("9") Then
DataEntryValidation = 0
Else
DataEntryValidation = Key
End If

Case "Amt"

If Key < Asc("0") Or Key > Asc("9") Then
If Key <> Asc(".") Then
DataEntryValidation = 0
Else
DataEntryValidation = Key
End If

Else
DataEntryValidation = Key
End If

Case "Chr"

Key = Asc(UCase(Chr(Key)))
If Key = 8 Or Key = 32 Then DataEntryValidation = Key: Exit Function

If Key < Asc("A") Or Key > Asc("Z") Then
DataEntryValidation = 0
Else
DataEntryValidation = Asc(UCase(Chr(Key)))
End If
Case "Cbo"
DataEntryValidation = 0
Case Else
DataEntryValidation = Asc(UCase(Chr(Key)))
End Select

End Function

Rate It Validates the Data Entry in a Text Box.



Private Sub Form_KeyPress(KeyAscii As Integer)
    
    If KeyAscii = 22 Then KeyAscii = 0: Exit Sub
    KeyAscii = DataEntryValidation(KeyAscii, ActiveControl.Tag)
    
End Sub


Download this snippet    Add to My Saved Code

It Validates the Data Entry in a Text Box. Comments

No comments have been posted about It Validates the Data Entry in a Text Box.. Why not be the first to post a comment about It Validates the Data Entry in a Text Box..

Post your comment

Subject:
Message:
0/1000 characters