Search Tools Links Login

Boolean function that compares two files to see if they are identical

This boolean function simply reads in two files and compares them to see if they are the same. It returns true if they are and false if they aren't. I quickly wrote this up to compare text files against template files.

Original Author: Blake Pell


Public Function compare_files(fileOne As String, fileTwo As String) As Boolean
  Dim fileOneContent As String
  Dim fileTwoContent As String
  Dim temp As String
  Open fileOne For Input As #1
  Do Until EOF(1)
    Line Input #1, temp
    fileOneContent = fileOneContent + temp
  Close #1
  Open fileTwo For Input As #1
  Do Until EOF(1)
    Line Input #1, temp
    fileTwoContent = fileTwoContent + temp
  Close #1
  If fileOneContent = fileTwoContent Then
    compare_files = True
    compare_files = False
  End If
End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 92 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.