ramone Posted October 5, 2005 Posted October 5, 2005 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 thank you Quote
techmanbd Posted October 5, 2005 Posted October 5, 2005 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 "/" 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 Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.