Unanswered: Replace specific character in Visual Basic
guys, please someone help in my code.The question is as following:
In a form, I have a text box named: txtName which contains customer name.
If the customer name is for example: Cindy's.
Then the txtName = "Cindy's"
Now, in my code, I need to check this txtName field. if contains the single prime ('), I need to replace it as two single primes('')
My code is:
Dim Oldtxt as String
Dim Newtxt as String
Dim ocn as new connect
Oldtxt = txtName.text
Newtxt = Oldtxt.Replace(" ' ", " '' ")
str = "Insert into tblName Values('" & Newtxt & "')"
I don't know can I achieve my goal by this code since when I debug, it returned that the .Replace method is not found. Then I tried InStr(), still not found.
Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!
Or try our Ask An Expert service to answer any of your questions!