Binary File Compare

These simple and quick to implement methods will help you to compare files at a binary level. To demo this project, add three command button controls and simply replace the file path and name in the click events of the command button controls. Then you could modify the code to except file selections from the common dialgue control.

Code:
Dim a As String
Dim s As String

Private Sub Command1_Click()
    Open "" For Binary As #1
    a = Space(LOF(1))
    Get #1, , a
    Close #1
    MsgBox "Pic number 1 captured.", vbOKOnly + vbInformation, "Picture Compare"
End Sub

Private Sub Command2_Click()
    Open "" For Binary As #1
    s = Space(LOF(1))
    Get #1, , s
    Close #1
    MsgBox "File number 2 captured.", vbOKOnly + vbInformation, "Picture Compare"
End Sub

Private Sub Command3_Click()
    If s = a Then
        MsgBox "The file is the same."
    Else
        MsgBox "The file is not the same."
    End If
End Sub

Private Sub Form_Load()
    Command1.Caption = "Load File 1"
    Command2.Caption = "Load File 2"
    Command3.Caption = "Compare Files"
End Sub

No comments:

Post a Comment

Post Comments


Do you have any suggestions ? Add comment. Do not spam!