How can I count text file row ?

  • Hi, all

    I have a Q for U:-)))

    I have a Active X script that makes Header & Trailer into the data text file. U can check my other discussion:-)))

    My Q is , how can I put data text record count in the trailer?

    What I mean by that is how can I count records that are in text file?

    I used COUNT method in Active X script but it did not work?

    Any idea????

    Thx in advance..

    Jay

  • I don't know if this will help, but here's what I did:

    'Count Records in Datafile

    Set FSO = CreateObject("Scripting.FileSystemObject")

    Set lfInputFile = FSO.GetFile(vPath&"\yourfilename")

    Set ltsInput = lfInputFile.OpenAsTextStream(ForReading)

    I=0

    Do While Not ltsInput.AtEndOfStream

    lsTemp = ltsInput.ReadLine

    I = I+1

    Loop

    ltsInput.Close

    Set ltsInput = Nothing

    Set lfInputFile = Nothing

    This enabled me to do a count of all the rows for inclusion in my trailer record.

    Edited by - ncaffee on 02/28/2002 12:40:05 PM

  • If they are fixed length rows you could subtract out the byte count for header and trailer, then divide remainder by the row length.

    Andy

  • Another option which might be a little overkill, would be to use the odbc text driver to access the file as a recordset. Then just check the value of the record count property.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply