Compare two text files in Vb6

January 31, 2010 at 03:54:40
Specs: Windows XP
Hey all,

I have a problem in comparing two text files in visual basic 6

First need to compare the first line of text files, and if its different, find the missing line(s)

Content of text file 1:

Content of text File 2:

someone guide me plzz

See More: Compare two text files in Vb6

Report •

Report •

January 31, 2010 at 05:25:24
Yes i did google..
But i couldnt understand
I hv zero programming knowledge in VB

Report •

February 1, 2010 at 05:36:17
I hv zero programming knowledge in VB

Report •

Related Solutions

February 1, 2010 at 12:49:50
this is assuming that both files are sorted (after the first line, which i am also assuming is the linecount of each file):

dim x$(2)
open "file1" for input as #1
open "file2" for input as #2
gosub read
if x$(2)>x$(1) then ex=val(x$(2)) else ex=val(x$(1))
do while not eof(ex)
for i=1 to 2
gosub read
next i
for i=1 to 2
if x$(3-i)>x$(i) then
print "file ";3-i;" is missing line ";x$(i)
goto xit
next i
print "files same"
goto xit

if eof(i) then print "eof";i : goto xit
line input #i,x$(i)

probably better suggestion: strip off the first line then do "fc" on the two files.
edlin: 1d,e will remove line 1 when set up corr.

Report •

February 2, 2010 at 00:47:29
Thanks alot nbrane,
However i also did some search and solved this problem
Just want share here for other to refer and learn;

FileA = "C:\LOGFILES\abc.log"
FileB = "C:\LOGFILES\cba.log"

Set fso = New FileSystemObject
Set FileA1 = fso.OpenTextFile(FileA, ForReading)
Count = 1
Do Until FileA1.AtEndOfStream
strMatch = False
strFileA = FileA1.ReadLine
Set FileB1 = fso.OpenTextFile(FileB, ForReading)
Do Until FileB1.AtEndOfStream
strFileB = FileB1.ReadLine
If Trim(UCase(strFileB)) = Trim(UCase(strFileA)) Then
strMatch = True
End If
'Avoid Difference in First Line
If Not (Count = 1) Then
If strMatch <> True Then
print strFileA
End If
If strMatch <> True Then
print "File Missing"
End If
End If
Count = Count + 1

Working fine to me, correct me if wrong!!!

Report •

Ask Question