Signature (Visual Basic / VBA)
Public Function CompareFiles( _
ByVal vFileOne As Variant _
, ByVal vFileTwo As Variant _
) As Variant
Code Examples
' Assumes C:\COMMAND.COM and C:\AUTOEXEC.BAT both exist
' and that they have different contents.
CompareFiles("C:\COMMAND.COM", "C:\COMMAND.COM") = 0
CompareFiles("C:\COMMAND.COM", "C:\AUTOEXEC.BAT") = 1
' #3 assumes C:\TEMP is a directory or an unused file name.
CompareFiles("C:\COMMAND.COM", "C:\TEMP") = -1 ' #3
1: File sizes differ OR file contents differ.
0: File sizes AND file contents are the same.
-1: There were errors accessing one or both files.
Parameters
| Parameter | Description |
|---|---|
| vFileOne | Name of the first of two files whose contents will be compared. Function returns Null if vFileOne is Null or cannot be fixed-up to a string. |
| vFileTwo | Name of the seconds of two files whose contents will be compared. Function returns Null if vFileTwo is Null or cannot be fixed-up to a string. |
Notes & Version History
| Note | The file dates and attributes may differ, but as long as the two files have the same size and contents then they will be considered the same by this function. |