How Do I: Find and Replace...

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Apr 21, 2004 6:09 am

It's been a while, but I recently had to visit this problem again. How to replace a double quote in the source file of a vbReplace function. Using a variable does not work on the source file. Eric D provided his final coding, but the solution to replace the quote was really buried in the middle. I have removed the relevant section to be easier to find in the future.
//VBScript to first remove any " from file.

VBSTART

Sub ReadEntireFile1 'reading file and storing it in ReadFile
Dim fs, f, ReadFile
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("c:\apps\mbmsnet\wanda\in\wanda.txt", 1,0)
ReadFile = f.ReadAll
f.Close

dim result
dim QuoteChar
QuoteChar = chr(34)
result = replace(ReadFile,QuoteChar," ")

Set f = fs.OpenTextFile("c:\apps\mbmsnet\wanda\in\wanda.txt", 2, True)

f.Write result

End Sub

VBEND

VBRun>ReadEntireFile1
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts