tags:

views:

17

answers:

1

hi I have the follwoing code , that find in the txt file the line that start with the : THIS_LOCATION and replace the OFF_LINE with NEW

if InStr(strText , 'THIS_LOCATION' ) then

strNewText = Replace(strText, "OFF_LINE", "NEW")

End if

the VB script failed on the line :

if InStr(strText , 'THIS_LOCATION' )

what wrong?

THX yael

A: 

You need double quotes:

If InStr(strText, "THIS_LOCATION") Then
Remou
OK its workbut its also replace in all txtmy target was to replace only in THIS_LOCATION linewhats wrong?
yael
If you are using information from my previous answers, it seems that strText contains all your text, rather than a single line. To read a line from a text stream got with the FileSystemObject, use ReadLine, not ReadAll. You can read line by line using `While Not f.AtEndOfStream` where f is the Textstream object.
Remou
See also: http://msdn.microsoft.com/en-us/library/z9ty6h50(VS.85).aspx
Remou