troubleshooting Question

Visual Basic Compare Documents

Avatar of -Geek
-Geek asked on
Visual Basic.NET
12 Comments1 Solution599 ViewsLast Modified:

 I am looking to compare documents to output the differences between them in Visual Basic. Looking for an add-on with clear directions on use and examples. What I am currently using is ok to compare, but if their is one word different then the detection is worthless.

Private Function FileCompare(ByVal file1 As String, ByVal file2 As String) As Boolean
        Dim file1byte As Integer
        Dim file2byte As Integer
        Dim fs1 As FileStream
        Dim fs2 As FileStream

        If (file1 = file2) Then
            Return True
        End If

        fs1 = New FileStream(file1, FileMode.Open)
        fs2 = New FileStream(file2, FileMode.Open)

        If (fs1.Length <> fs2.Length) Then
            Return False
        End If

            file1byte = fs1.ReadByte()
            file2byte = fs2.ReadByte()
        Loop While ((file1byte = file2byte) And (file1byte <> -1))


        Return ((file1byte - file2byte) = 0)
    End Function
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros