View Single Post
  #2 (permalink)  
Old December 20th, 2004, 04:02 PM
mmcdonal mmcdonal is offline
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

It seems that what you are trying to do with your flow control is that you are reading a single line from txtFile.1, and then reading every line from txtFile2.txt to compare them, and then moving on to the next line in txtFile1.txt, and comparing it to every line in txtFile2.txt, etc.

But the way this is looping through, it is reading Line1 from text file 1, then all the lines in text file 2, then the remaining lines from text file 1.

The reason it is doing this is that after it loops through all the lines in text file 2, it IS AtEndOfStream, so it won't loop through subsequent iterations. The boolean is set to True. No more looping.

You need to reset the inner loop for every iteration of the outer loop.

THEN, your variable checking is wrong.

Then, you're actually asking it to print a line from the first text file, and a line from the second text file when the lines don't match, and they don't match in every case but one, so you will get a very large output in the results.txt file.

I have no idea what this "Removed" is for:
'=================================
Else Removed
      f.WriteLine strLine1 & " " & strLine2 Removed
'=================================

I rewrote it like this to get it to work:
'=================================
Else f.WriteLine strLine1 & " " & strLine2
'=================================

I hope this gets you started. I am not sure why you are using Trim instead of InStr unless the data is not very unique in every line.

As an alternative, consider pumping this through an Access database, setting up a query to find unmatched lines, then pumping out the dynaset to your text file. That would be easier for me.



mmcdonal
Reply With Quote