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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with ?replace?

Status
Not open for further replies.

Goblinlord

Programmer
Joined
Jul 1, 2001
Messages
4
Location
US
1}

I am having trouble with some code i am using to have an input file and have this script go through the file and replace certain strings. But it keeps giving me an error that says: Object required: '[String: &quot;<everything in my input file>&quot;]'

2}

How do you put the character &quot; in a string?

Here is my code that is messing up.
<--

Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set cab = fs.OpenTextFile(&quot;c:\ben stuff\vbs\cab.txt&quot;, 1)
a1 = &quot;ad&quot;
a2 = &quot;cab&quot;
Set b = cab.ReadAll
Set c = b.Replace(a1, a2)
Set cabed = fs.CreateTextFile(&quot;c:\ben stuff\vbs\cabed.txt&quot;, True)
cabed.writeline(c)
a.Close
cabed.close
-->



 
Set b = cab.ReadAll
Set c = b.Replace(a1, a2)
Take off the Sets. You are creating a strings, not objects and Replace is a method of a hidden global object.
b = cab.ReadAll
c = Replace(a1, a2)
' &quot;
B = &quot;&quot;&quot;Hello World&quot;&quot;&quot;&quot; ' double up
' or use Chr(34)
B = Chr(34) & &quot;Hello World&quot; & Chr(34)

 
oh ... duh.
smiletiniest.gif
thanx
 
c = Replace(a1, a2)
That should be
c = Replace(b,a1, a2)
and don't forget the 0=BINARYCOMPARE or 1=TEXTCOMPARE.
Our INSET is slow today so I can't look it up.
c = Replace(b,a1, a2,,0) ' Binary? Case matters
c = Replace(b,a1, a2,,1) ' Text? Case no matter

 
Thanx... i knew that but thanx anyways. i got it to work with what you told me to do first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top