by Ulysses R. Gotera (9 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 29th July 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Allow only numbers in your textbox control
API Declarations
' Sample Usage:
'Private Sub Textbox1_KeyPress(KeyAscii As Integer)
' NumOnly KeyAscii
'End Sub
' **************************************************
' Description : Allows only numbers in your text box.
' Author : Ulysses R. Gotera
' Date Created: Friday, July 01, 2005
' **************************************************
If p_intKeyAscii = 46 Then Exit Sub ' Allows a period.
If p_intKeyAscii = vbKeyReturn Then Exit Sub
If p_intKeyAscii = vbKeyTab Then Exit Sub
If Not (p_intKeyAscii > 47 And p_intKeyAscii < 59) Then
If Not p_intKeyAscii = vbKeyBack Then
p_intKeyAscii = 0
End If
End If
End Sub