VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Allow only numbers in your textbox control

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

Rate Allow only numbers in your textbox control



' **************************************************
'    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

Download this snippet    Add to My Saved Code

Allow only numbers in your textbox control Comments

No comments have been posted about Allow only numbers in your textbox control. Why not be the first to post a comment about Allow only numbers in your textbox control.

Post your comment

Subject:
Message:
0/1000 characters