You should first check this link for learning more about writing/reading from files.
So you should do something like this (supposing that each record in on a different line):
Code:
Dim strtextfile As String
Dim strtextfile1 As String
Dim strtextfile2 As String
Dim strtextfile3 As String
Dim lines() as String
dim logic as boolean
dim duplicate as string
dim nonduplicate as string
hfile = FreeFile
Open "file1.txt" For Input As #hfile
strtextfile1 = Input$(LOF(hfile), hfile)
Close #hfile
hfile = FreeFile
Open "file2.txt" For Input As #hfile
strtextfile2 = Input$(LOF(hfile), hfile)
Close #hfile
hfile = FreeFile
Open "file3.txt" For Input As #hfile
strtextfile3 = Input$(LOF(hfile), hfile)
Close #hfile
' and so on until 5
' after than concatenate them into a single file
strtextfile=strtextfile1 & vbcrlf & strtextfile2 & vbcrlf & strtextfile3
' after that split the string by the vbcrlf character (newline)
lines=split(strtextfile,vbcrlf)
' then check each value to see if it's a duplicate
for i=0 to ubound(lines)-1
logic=true
for j=i+1 to ubound(lines)
if lines(i)=lines(j) and (lines(i) <>"" or lines(j) <> "") then
duplicate=duplicate & vbcrlf & lines(i)
lines(j)=""
logic=false
end if
next j
' if no duplicate found then add that line to nonduplicates
if logic then
nonduplicate=nonduplicate & vbcrlf & lines(i)
end if
next i
' then write the duplicate to the duplicate.txt and nonduplicate to nondup.txt or wherever you want
I've written this code now for giving you a general idea on how you should think this problem... don't copy-paste it because it won't work 
|
Last edited by an5w3r; 08-25-2004 at 02:40 AM.
|