by TJ Shreves (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 13th October 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Restricting text boxes to numeric text only
API Declarations
I found that the "backspace" method froze my program quiet often, so I modified it to read a little differently.
How this works is quiet simple. It states that if a non-numeric text is entered, then the text box will read as whatever is in the quotations(""). So if the quotations("") are left empty as shown, then the text box will read as as if the text box were cleared. It has the same effect as the "backspace" method, just more addaptable. You could enter a phrase or comment in the quotations to advice the user to use numeric text only, ie.("numeric text only").
If Not IsNumeric(Text1.Text) Then Text1.Text = ""
End Sub