hello
how can i block users from entering special sql characters in textboxes, like # ' \ " and -- ?
i know it can be done with the keypress event of the textbox but i don't know how exactly
this here only allows numbers and the backspace keys to work in the textbox.
So hopefully this can send you in the right direction.
you can also get the decimal number for an individual key and use an expression down below with the sub I provided
Asc(e.KeyChar) = 47 ' this would be for "/"
Code:
Private Sub txtMaxTrans_Keydown(ByVal sender As System.Object, ByVal e As KeyPressEventArgs) Handles txtMaxTrans.KeyPress
If Not Char.IsNumber(e.KeyChar) And Not Asc(e.KeyChar) = Keys.Back Then
e.Handled = True
End If
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.