CodeItBetter Programming Another VB Programming Blog

How to Prevent the user from entering invalid keys in a text box.

Posted on July 19, 2011
1
2
3
4
5
6
7
8
9
'Controls - How to Prevent the user from entering invalid keys in a text box.
Private Sub Text1_KeyPress(KeyAscii As Integer)
    Select Case KeyAscii
    Case Is < 32               ' Control keys are OK.
    Case 48 To 57              ' This is a digit.
    Case Else                  ' Reject any other key.
        KeyAscii = 0
    End Select
End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.