vb.net - Only accept digits for textbox -


i found code making textbox accept numbers.

private sub textbox1_keypress(byval sender system.object, byval e system.windows.forms.keypresseventargs) handles textbox1.keypress     dim allowedchars string = "0123456789"     if allowedchars.indexof(e.keychar) = -1         ' invalid character         e.handled = true     end if end sub 

but... user can't delete numbers using backspace button. how do then?

you need handle pasted text (there may not keypress). best way maskedtextbox.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -