VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Only allow numbers AND control codes (i.e. backspace) to be entered in a text box

by Lee Turner (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Tue 3rd July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Only allow numbers AND control codes (i.e. backspace) to be entered in a text box

Rate Only allow numbers AND control codes (i.e. backspace) to be entered in a text box



Call KeyCheck(KeyAscii)
End Sub

Public Function KeyCheck(ByRef KeyAscii As Integer)
'Disallow the user to enter anything other than numbers and control codes
   If KeyAscii < 48 Or KeyAscii > 57 Then 'disallow anything other than numbers
   If KeyAscii = 8 Or KeyAscii = 9 Or KeyAscii = 10 Or KeyAscii = 13 Then 'allow all the control codes though...
   KeyAscii = KeyAscii
   Else
      KeyAscii = 0
      End If
   End If
End Function

Download this snippet    Add to My Saved Code

Only allow numbers AND control codes (i.e. backspace) to be entered in a text box Comments

No comments have been posted about Only allow numbers AND control codes (i.e. backspace) to be entered in a text box. Why not be the first to post a comment about Only allow numbers AND control codes (i.e. backspace) to be entered in a text box.

Post your comment

Subject:
Message:
0/1000 characters