Jobs
Author: Ulysses R. Gotera Date Submitted: 7/29/2005 Category: Microsoft Controls Compatibility: VB 6,VB 5 This code has been accessed 5504 times.
Email Yourself this snippet:
' Add this in your BAS file. ' Sample Usage: 'Private Sub Textbox1_KeyPress(KeyAscii As Integer) ' NumOnly KeyAscii 'End Sub
Code
Public Sub NumOnly(ByRef p_intKeyAscii As Integer) ' ************************************************** ' 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