VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



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

by BP (8 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (3 Votes)

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.

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

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
  Loop
  Close #1
  
  Open fileTwo For Input As #1
  Do Until EOF(1)
    Line Input #1, temp
    fileTwoContent = fileTwoContent + temp
  Loop
  Close #1
  
  If fileOneContent = fileTwoContent Then
    compare_files = True
  Else
    compare_files = False
  End If
  
End Function

Download this snippet    Add to My Saved Code

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

No comments have been posted about Boolean function that compares two files to see if they are identical. Why not be the first to post a comment about Boolean function that compares two files to see if they are identical.

Post your comment

Subject:
Message:
0/1000 characters