how do I set a Textbox to only accept numerical values in vb .net
how do I set a Textbox to only accept numerical values in vb .net
Collapse
X
-
Originally posted by sannihithhow do I set a Textbox to only accept numerical values in vb .net
Code:Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyValue < 48 Or e.KeyValue > 57 Then e.SuppressKeyPress = True End If End Sub
-
-
Hi there,
If you wanna apply server side validation for not allowing anything else then numbers use the acii code present in second solution but it is advised to use client side validation ie in your vb.net toolbar, use regular expression validator..for that validator in the properties window enter a regular expression.
Hope this help..
RegardsComment
Comment