Click to See Complete Forum and Search --> : File I/O??
Falcondl
Nov 9th, 1999, 07:05 AM
I'm having a rough time with file I/O.
I have a file with data delimited by newlines.
I want to be able to search through the data for a matching string, and then remove it.
Also, is there a way to specify what line to start on? in case i wanted to make something that could advance through all this data one at a time, and the user could change a specific entry?
Any help would be greatly appreciated. Thanks.
~Falc
smalig
Nov 9th, 1999, 03:05 PM
I think you need
1. open your file and to search for a line
2. create new file and to copy data which to you are necessary
3. delete first file and rename second file
------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)
onerrorgoto
Nov 9th, 1999, 06:47 PM
Check out this tutorial here on VB-World.
It searches thru a word dokument for specific values and changes them or remove them.
It might not be exactly what you are talking about, but maybe it will help you in the right direction http://www.vb-world.net/activex/wordreports/
------------------
******
Anders
anders@zsystemdesign.se
*******
mcleran
Nov 9th, 1999, 09:14 PM
You can do all of what you want with the file system object and textstream object. Add a reference to Microsoft Scripting Runtime and check out the MSDN help on working with the file system object. Here's a couple of little examples:
**Read an entire text file into a string**
Dim f as FileSystemObject
Dim ts as TextStream
Dim sTemp as String
'instantiate file system object
Set f = New FileSystemObject
'point textstream to text file
Set ts = f.OpenTextFile(pathtofile,ForReading)
'read entire file into string var
Do
sTemp = sTemp & ts.ReadLine
Loop Until ts.AtEndOfStream = True
'kill objects
ts.Close
Set ts = Nothing
Set f = Nothing
**You can use the SkipLine method of the TextStream Object to skip lines in the file**
ts.SkipLine
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.