The crude routine below susprises me.

It doesn't appear to fail with the LOC/LOF test, and it doesn't fail when only part of a 10,000 chunk is read.

I don't mind, really. I am using it to compare files of MP3 types (hence the larg buffer size), and it works fine with buffer lengths of 1 and 10 and 100 on various tests with my Autoexec files.

That is, I am satisfied that it is detecting errors at all the right places.

I had thought that I would have to write a "now compare the remaining characters in the partial block" code.



I'm also seeking comments on the InputB function.



<pre>Option Explicit
Private Const intcLength As Integer = 10000
Sub udfFileCompare()

' Compare two files, bit-for-bit
Dim strFileOne As String
Dim intOne As Integer
Dim strFileTwo As String
Dim intTwo As Integer
strFileOne = "c:autoexec.bat"
strFileTwo = "c:autoexec.bak"
' Open files
intOne = FreeFile
Open strFileOne For Binary As intOne
intTwo = FreeFile
Open strFileTwo For Binary As intTwo

' If length different then files are different
If LOF(intOne) <> LOF(intTwo) Then
MsgBox "fles are of different length"
Else
Do While Loc(intOne) < LOF(intOne) ' Loop until end of file.
If Input(intcLength, #intOne) <> Input(intcLength, intTwo) Then
MsgBox "different text at " & Loc(intOne)
Exit Do
Else
End If
Application.StatusBar = LOF(intOne) & " " & Loc(intOne)
Loop
End If

Close intOne
Close intTwo
End Sub
</pre>