Avatar of -Geek
-Geek

asked on 

Visual Basic Compare Documents

Greetings,

 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
            fs1.Close()
            fs2.Close()
            Return False
        End If

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

        fs1.Close()
        fs2.Close()

        Return ((file1byte - file2byte) = 0)
    End Function

Open in new window

Visual Basic.NET

Avatar of undefined
Last Comment
-Geek
Avatar of aikimark
aikimark
Flag of United States of America image

1. Are these text/document type files or binary data?
2. How will the output of this function be used?
Avatar of -Geek
-Geek

ASKER

These are word documents, the Microsoft comparison above is a byte by byte I believe.
Avatar of aikimark
aikimark
Flag of United States of America image

Do your users have Word on their systems?  If so, why not use Word's document comparison functionality?
Avatar of -Geek
-Geek

ASKER

They don't I had thought about that already.
Avatar of aikimark
aikimark
Flag of United States of America image

If the users do not have Word on their PCs, then why are they trying to compare their contents?!?

Have you looked at the Open Office SDK?  I know that it allows your VB.Net program to work with documents, especially the .docx format.  That will be helpful in parsing the contents of the documents.

I would recommend looking at some libraries or utilities that do document comparison and see if you might be able to launch them from your application and then present the results.

Is it possible to use these two documents as parameters to a web service call?  Maybe you can install Word on your server.
Avatar of -Geek
-Geek

ASKER

Didn't think if that, do you have any links?
ASKER CERTIFIED SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of -Geek
-Geek

ASKER

I have about 7 - 10 documents to compare to 1, and most I found for that are in c#. Do you know of any examples in VB that I could utilize? Looks promising.
Avatar of aikimark
aikimark
Flag of United States of America image

do it manually.  For that few documents, you shouldn't expend any of your time coding.
Avatar of -Geek
-Geek

ASKER

7 - 10 at a time, it spans in the upwards of sometimes 30 documents, and this is by 5 individuals so it's quite a large task ( 5 x 30 ). Sorry for not being clear enough. I am looking to add more folks to the document pool so currently at 5 but don't want to add more until I can nail this task.
SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of -Geek
-Geek

ASKER

Thank you very much, will open further questions around findings.
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo