Open a text file and edit using ReadLine method 
Author Message
 Open a text file and edit using ReadLine method

I want to open a text file and edit using the readline
method. I want to read line by line an if I find the
word "ERROR" i want to delete the whole line. I'm thinking
of reading my input file and only writing the good lines
to a new text file. Do i have to open the text file as an
object or what? Thanks for the help....Brad


Sun, 02 Oct 2005 02:46:34 GMT  
 Open a text file and edit using ReadLine method
Quote:

> I want to open a text file and edit using the readline
> method. I want to read line by line an if I find the
> word "ERROR" i want to delete the whole line. I'm thinking
> of reading my input file and only writing the good lines
> to a new text file. Do i have to open the text file as an
> object or what? Thanks for the help....Brad

Hi, Brad

Something like this: (untested code)

set filesys = CreateObject("Scripting.FileSystemObject")
set readfile = filesys.OpenTextFile("c:\somefile1.txt", 1, false)
Set WriteFile = filesys.CreateTextFile("c:\somefile2.txt")
do while readfile.AtEndOfStream <> true
    strTemp = readfile.ReadLine
    if instr(ucase(strTemp), "ERROR")) = 0 then WriteFile.WriteLine
loop
readfile.close
WriteFile.close

-Paul Randall



Sun, 02 Oct 2005 04:45:54 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Open a text file and edit using ReadLine method

2. Using the FileOpen dialog to find a file to open so I can use ReadLine method

3. Loading text file using StreamReader.Readline()

4. Using the ReadLine method for TextStream object

5. Opening text file in a text box using common dialog

6. using isam text driver to open comma delimited text file

7. fast readLine() using readFile() - scanning a file for vbCrLf

8. Open a text file using vbscript

9. StreamReader.Readline method

10. opening / saving files with MS rich text box control (viewing open files)

11. Best methods to open/edit dBase databases?

12. Using Open Statement to import a long text file in Access

 

 
Powered by phpBB® Forum Software