Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng 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
Joined
Nov 24, 2010
Messages
226
Location
DK
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
 
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

Back
Top