Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2005, 03:29 PM
Authorized User
 
Join Date: Jun 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default Undo/delete ' (single quote) in a textbox

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

__________________
------------------------
http://www.indrajal.com
 
Old April 6th, 2005, 04:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Your better off to replace the single quote before submitting it to the database. You want to have your user think as little as possible.

Also note that if you use SQL parameters within your query you shouldn't have this problem.

J





Similar Threads
Thread Thread Starter Forum Replies Last Post
single quote problem harpua PHP Databases 1 July 8th, 2005 07:37 AM
How to add parameter val containing single quote prog ADO.NET 3 May 24th, 2005 09:24 AM
replace single Quote qadeerahmad General .NET 3 September 6th, 2004 08:10 PM
problem caused by single quote isheikh BOOK: Beginning ASP 3.0 1 April 16th, 2004 02:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.