Results 1 to 4 of 4

Thread: File I/O??

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    39

    Post

    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

  2. #2
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    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
    [email protected]
    smalig.tripod.com

  3. #3
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post

    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
    [email protected]
    *******

  4. #4
    Member
    Join Date
    Jan 1999
    Location
    Longmont,CO
    Posts
    53

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width