VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Allow only numbers in a textbox

by RayDance (1 Submission)
Category: VB function enhancement
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (5 Votes)

This program won't allow any other characters in a textbox then numbers and it allows you to use your Backspace key.

Rate Allow only numbers in a textbox

Private Sub text1_KeyPress(KeyAscii As Integer)
  Dim Numbers As Integer
  Dim Msg As String
  
  Numbers = KeyAscii
  
  If ((Numbers < 48 Or Numbers > 57) And Numbers <> 8) Then
   Msg = MsgBox("Only Numbers are aloud in this Textbox", vbCritical, "Error Number")
   KeyAscii = 0
  End If
End Sub

Download this snippet    Add to My Saved Code

Allow only numbers in a textbox Comments

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

Post your comment

Subject:
Message:
0/1000 characters