Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If IsNumeric(TextBox1.text) = false then
textbox1.text = textbox1.text.substring(0, len(textbox1.text) - 1)
catch ex as exception
textbox1.text = ""
If you generally want to capture a keyboard event (entire form, anywhere), you first need to on formload set:
KeyPreview = True
Then you do something like:
Private Sub Key_Click(ByVal sender as Object, ByVal e as System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
if isnumeric(e.keydata.tostring) = false then
If this helped you, mark it as solved and/or give me some reputation points.
there are better to not allowed user to input alphabetic character. So, when user press keyboard keys, u can handled it by code to not allowed them to input alphabetical character.
this following code will not allowed you to input except number :
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _
Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...