Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Binary Files Comparison

Binary Files Comparison

Scheduled Pinned Locked Moved Visual Basic
questionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mayVB6
    wrote on last edited by
    #1

    I m doing on a project which requires me to do a binary file comparison. Can anyone help? How do i go abt coding it?

    D 1 Reply Last reply
    0
    • M mayVB6

      I m doing on a project which requires me to do a binary file comparison. Can anyone help? How do i go abt coding it?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Sounds like a homework project. We can't write the code for you. You'll have to start writing the code and then we can help with specific problems. RageInTheMachine9532

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Sounds like a homework project. We can't write the code for you. You'll have to start writing the code and then we can help with specific problems. RageInTheMachine9532

        M Offline
        M Offline
        mayVB6
        wrote on last edited by
        #3

        Private Sub CompareBinaryFiles(t1 As String, t2 As String) Open txtOne.Text For Binary Access Read As #1 Open txtTwo.Text For Binary Access Read As #2 Dim pos As Long Dim differencepercentage As Single Dim o As Byte, t As Byte Dim textOne As String, textTwo As String Dim totalcount As Integer, differencecount As Integer 'need to initalize before computing totalcount = 0 differencecount = 0 On Error GoTo exit2 'loop the file until EOF Do Until EOF(2) 'count + 1 whenever the file loop totalcount = totalcount + 1 'calculating the positioning of the file pos = pos + 1 pos2 = pos2 + 1 If pos > txtOne Then GoTo exit2 Get #1, pos, t Get #2, pos, o 'add the countdiffernces by 1 If t <> o Then lstMistakes.AddItem "Byte " & pos & " - " & t & " (" & o & ")" If t <> o Then differencecount = differencecount + 1 'DoEvents If pos Mod 256 = 0 Then PB.Value = pos Loop GoTo esc exit2: If pos2 = cut Then GoTo esc lstMistakes.AddItem "---File ended at byte " & pos2 & " ---" esc: lstMistakes.Visible = True PB.Visible = False Close #1 Close #2 'calculating the percentage of the differnces of files On Error GoTo errhandler 'differencepercentage = (differencecount / totalcount) * 100 List2.AddItem "Binary Compare Similarity :" & 100 - differencepercentage & " %" List2.AddItem "Binary Compare diffences :" & differencepercentage & " %" Exit Sub errhandler: Resume Next End Sub Is this the way to do the binary files comparison? But when i include this function my normal text files comparison will have a extra line at the end of each documents!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups