Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SSS148 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace triple quotes to single quote >> vb.net

Status
Not open for further replies.

lklo

Industrial
Nov 24, 2010
226
Hi -
In a small journal I'm playing around on how to replace some """ in a text file , which contains some words surrounding three quotes on each side of these words...
I want to remove two of the quotes on each side of all words in txt file ....
Ex. """MyName""" >>>> "MyName"

I need a little help on syntax ....
I have tried the Vb . Replace function, but seeems a little tricky because it is quotes..

Regard lklo
 
Replies continue below

Recommended for you

If you want the string variable to include literal double quote characters within the string, then simply assign the original value to a string variable:
Code:
dim myString as string = """MyName"""
The value of the string variable will be: "MyName". This is useful if you want to create a string expression (see the "create a string expression" section of this article).

If you want to strip out the double quotes so that they do not appear in the string value, there are multiple ways to do it; below are two:

Code:
Option Strict Off
Imports System
Imports NXOpen

Module Module75

    Dim theSession As Session = Session.GetSession()
    Dim lw As ListingWindow = theSession.ListingWindow


    Sub Main()

        lw.Open()

        Dim strInput As String = """MyName"""
        lw.WriteLine("strInput: " & strInput)

        Dim strOutput As String
        strOutput = strInput.Replace("""", "")
        'chr(34) = "
        'alternatively, you can replace chr(34) with an empty string
        'strOutput = strInput.Replace(Chr(34), "")

        lw.WriteLine("strOutput: " & strOutput)

        lw.Close()
    End Sub

End Module

www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor