| |
danielc
Posts: 10
Score: 0
Joined: 3/2/2007
Status: offline
|
Hello folks, I am attempting to compare two files. If the lines match in the file then it writes the match to another file. But that doesn't work. If I change the variable 'mytag' to True then I only get one line written to the file and then quits. What am I doing wrong? My code is as follows: Set objFSO = CreateObject("Scripting.FileSystemObject") Const ForReading = 1 File1 = "C:\Idlink.txt" File2 = "C:\photo.txt" wfile = "C:\compdfile.txt" Set aFile = objFSO.GetFile(File1) Set aaFile = aFile.OpenAsTextStream(1,-2) Set bFile = objFSO.GetFile(File2) Set bbFile = bFile.OpenAsTextStream(1, -2) Set cFile = objFSO.OpenTextFile(wfile, 8, True) Do Until aaFile.AtEndOfStream line1 = aaFile.ReadLine Loop mytag = False Do Until bbFile.AtEndOfStream line2 = bbFile.ReadLine If line2 = line1 Then myTag = True Exit Do End If Loop If myTag = True Then cfile.WriteLine line1 End If aaFile.Close bbFile.Close MsgBox "Complete" Thanks in advance for all your help, Dan
|
|