What's Here?
- Members: 137,219
- Replies: 481,450
- Topics: 75,056
- Snippets: 2,567
- Tutorials: 675
- Total Online: 2,230
- Members: 106
- Guests: 2,124
|
A method to allow the user to enter only certain specific characters into a text box and ignore any other key. In this example only numbers, the Backspace key and the period will be allowed, everything else is ignored.
|
Submitted By: Jayman
|
|
Rating:
 
|
|
Views: 12,174 |
Language: VB.NET
|
|
Last Modified: August 9, 2006 |
|
Instructions: Put this code inside the KeyPress event for any text box that you want to limit user input. |
Snippet
'allow only numbers, the Backspace key and the period
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then
'cancel keys
e.Handled = True
End If
Copy & Paste
|
|
|
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|