How to escape a string with double quote in VB.NET

How to escape a string with double quote in VB.NET ?
Sam OZAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
s = "hello \" in quotes \" "

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Shaun VermaakTechnical SpecialistCommented:
I prefer the previous method but just for completeness
sss = @"hello ""in quotes"" "

Open in new window

Sam OZAuthor Commented:
Thanks. What I am really looking is a way to have the escape added to a value in a stirng

 dim mystring as string
   ... Routine to call Sql Server DB and fill mysting
   ... Escape the double quote in MyStirng

  In the pseudocode above it is the escape that I am looking for
Ryan ChongSoftware Team Lead, ex-Business Systems Analyst , ex-Senior Application EngineerCommented:
escape a string with double quote
what's the purpose of having this feature?

Routine to call Sql Server DB and fill mysting
are you calling a stored procedure or some other SQL statements?

can you share some of the codes here?
AndyAinscowFreelance programmer / ConsultantCommented:
So in that case use the String.Replace functionality.

copied from link
Module Example
   Public Sub Main()
      Dim s As String = "aaa"
      Console.WriteLine("The initial string: '{0}'", s)
      s = s.Replace("a", "b").Replace("b", "c").Replace("c", "d")
      Console.WriteLine("The final string: '{0}'", s)
   End Sub
End Module
' The example displays the following output:
'       The initial string: 'aaa'
'       The final string: 'ddd'

hint, replace all instances of " with \"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.