Hi,
I have a multiline textbox, and i store the content of the textbox in a sql server DB. But problem arises when someone types ' (single quote). What i want to do is pop up a msgbox and then delete the ' (single quote) but keep the other content untouched.
I tried to use keypress event handler with textbox.undo property but the event undoes all text but the ' (single quote).
Below is my code:
Code:
Private Sub txtDescription_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDescription.KeyPress
If e.KeyChar = ("'"c) Then
txtDescription.undo
MsgBox("Error: Single Quote is not Allowed in this field!", MsgBoxStyle.OKOnly, " ' Not Allowed")
Exit Sub
End If
End Sub
Thanks in advance