Results 1 to 3 of 3

Thread: file compare bit by bit...

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Land of Entrapment
    Posts
    31
    Hey all,
    Remember the old DOS compare command? Is there a VB control anyone is aware of that will do same kind of bit by bit file comparison?
    Thnx!

  2. #2
    Guest
    This something of what you want?

    Code:
    Sub file_compare(file1 As String, file2 As String)
    'this checks two files to see if they are identical
    
    Open file1 For Binary As #1
     Open file2 For Binary As #2
     
     issame% = True
     If LOF(1) <> LOF(2) Then
     issame% = False
     Else
     Whole& = LOF(1) \ 10000 'number of whole 10,000 byte chunks
     Part& = LOF(1) Mod 10000 'remaining bytes at end of file
     buffer1$ = String$(10000, 0)
     buffer2$ = String$(10000, 0)
     Start& = 1
     For X& = 1 To Whole& 'this for-next loop will get 10,000
    Get #1, Start&, buffer1$ 'byte chunks at a time.
    Get #2, Start&, buffer2$
    
           If buffer1$ <> buffer2$ Then
                   issame% = False
                   Exit For
           End If
    
    Start& = Start& + 10000
     Next
     buffer1$ = String$(Part&, 0)
     buffer2$ = String$(Part&, 0)
     Get #1, Start&, buffer1$ 'get the remaining bytes at the end
     Get #2, Start&, buffer2$ 'get the remaining bytes at the end
     If buffer1$ <> buffer2$ Then issame% = False
     End If
     
     Close
     If issame% Then
     MsgBox "Files are identical", 64
     Else
     MsgBox "Files are NOT identical", 16
     End If
    End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Land of Entrapment
    Posts
    31
    Now did you just whip this up or did you have that code somewhere?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width