File processing with VB
-
Hi Folks I have got something for you to think about...the thing is i have a text file which contains huge dataset( delimited records). It has a trailer at the end which will have the record count and other relevant information about the text file. Now i need to verify whether the record count mentioned in the trailer is correct. i am right now doing this by looping through entire file and incrementing the count. The issue is since this is a line by line read operation its taking hell alot of time. These are the questions Is there a way through which we can find how many lines in a file. Is there a way to read the entire file as a stream in VB6.0. Please help me asap Best Regards Venkatraman Kalyanam Chennai - India "Being Excellent is not a skill, it is an attitude"
-
Hi Folks I have got something for you to think about...the thing is i have a text file which contains huge dataset( delimited records). It has a trailer at the end which will have the record count and other relevant information about the text file. Now i need to verify whether the record count mentioned in the trailer is correct. i am right now doing this by looping through entire file and incrementing the count. The issue is since this is a line by line read operation its taking hell alot of time. These are the questions Is there a way through which we can find how many lines in a file. Is there a way to read the entire file as a stream in VB6.0. Please help me asap Best Regards Venkatraman Kalyanam Chennai - India "Being Excellent is not a skill, it is an attitude"
You can use the FileSystemObject to do this.First of all, add a reference to "Microsoft Scripting Runtime". The add the followinf code (more or less) : ********************************************************************** Dim FSys as New FileSystemObject Dim txtStr as TextStream, iLine as Integer Set txtStr = FSys.OpenTextFile (FileName) Do While Not (txtStr.AtEndOfStream) txtStr.SkipLine Loop iLine = txtStr.Line ********************************************************************** This should be faster than reading the whole text file line by line :)