by Kenneth Gilbert Jr. (2 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)
With this 1 line of code you can strip non-numerical input into text boxes.
Private Sub Text1_KeyPress(KeyAscii As Integer)
' Force numbers only in a text box
If IsNumeric(Chr(KeyAscii)) <> True Then KeyAscii = 0
End Sub