' =============================================================
' function: CompareFiles
' desc : Compares two text files
' params : strFile1 is the first file
' strFile2 is the second file
' returns : True if they are the same, False otherwise
' =============================================================
Function CompareFiles(strFile1, strFile2)
Dim objFS
Dim objFileA, objFileB
Dim strLineA, strLineB
dim intCompareResult
' create a file scripting object
Set objFS = CreateObject("Scripting.FileSystemObject")
' open each of the files for reading
Set objFileA = objFS.OpenTextFile(strFile1, 1)
Set objFileB = objFS.OpenTextFile(strFile2, 1)
' repeat the following until we hit the end of one of the files
Do While ((objFileA.AtEndOfStream <> True) OR (objFileB.AtEndOfStream <> True))
' read the next line from both files
strLineA = objFileA.ReadLine
strLineB = objFileB.ReadLine
' perform a comparison on the line from each file
intCompareResult = StrComp(strLineA,strLineB,0)
' if the value of the comparison is not 0, lines are different
If (intCompareResult <> 0) Then
' found a difference in the files, so close them both
objFileA.Close
objFileB.Close
' destroy the object
Set objFS = Nothing
' return false
CompareFiles = False
' exit the function
Exit Function
End If ' if different
Loop ' until end of file
' close both files
objFileA.Close
objFileB.Close
' destroy the object
Set objFS = Nothing
' if function got this far, means files are the same, so return True
CompareFiles = True
End Function 'CompareFiles
' function: CompareFiles
' desc : Compares two text files
' params : strFile1 is the first file
' strFile2 is the second file
' returns : True if they are the same, False otherwise
' =============================================================
Function CompareFiles(strFile1, strFile2)
Dim objFS
Dim objFileA, objFileB
Dim strLineA, strLineB
dim intCompareResult
' create a file scripting object
Set objFS = CreateObject("Scripting.FileSystemObject")
' open each of the files for reading
Set objFileA = objFS.OpenTextFile(strFile1, 1)
Set objFileB = objFS.OpenTextFile(strFile2, 1)
' repeat the following until we hit the end of one of the files
Do While ((objFileA.AtEndOfStream <> True) OR (objFileB.AtEndOfStream <> True))
' read the next line from both files
strLineA = objFileA.ReadLine
strLineB = objFileB.ReadLine
' perform a comparison on the line from each file
intCompareResult = StrComp(strLineA,strLineB,0)
' if the value of the comparison is not 0, lines are different
If (intCompareResult <> 0) Then
' found a difference in the files, so close them both
objFileA.Close
objFileB.Close
' destroy the object
Set objFS = Nothing
' return false
CompareFiles = False
' exit the function
Exit Function
End If ' if different
Loop ' until end of file
' close both files
objFileA.Close
objFileB.Close
' destroy the object
Set objFS = Nothing
' if function got this far, means files are the same, so return True
CompareFiles = True
End Function 'CompareFiles
Hello! This is my first comment here so I just wanted to give a quick shout
ReplyDeleteout and say I genuinely enjoy reading your blog posts.
Can you suggest any other blogs/websites/forums that go over
the same subjects? Appreciate it!
Also visit my page - minecraft game
Excellent blog post. I definitely appreciate
ReplyDeletethis site. Continue the good work!
My webpage; quest bars
I've been exploring for a little bit for any high-quality articles or weblog posts
ReplyDeletein this kind of house . Exploring in Yahoo I finally stumbled upon this site.
Studying this info So i'm happy to exhibit that I have an incredibly excellent uncanny
feeling I found out just what I needed. I so much
definitely will make certain to do not forget this website and give it a look regularly.
my web-site facebook quest protein bar
Hey there just wanted to give you a quick heads up. The words in your article seem to be running off the screen in Ie.
ReplyDeleteI'm not sure if this is a formatting issue or something to do with internet browser compatibility but I figured I'd post
to let you know. The layout look great though!
Hope you get the issue resolved soon. Kudos
Here is my weblog :: Where Can You Buy Quest Protein Bars
I think that everything said was very reasonable.
ReplyDeleteHowever, what about this? what if you were to create a killer headline?
I mean, I don't want to tell you how to run your blog, however
what if you added a title to possibly get folk's attention? I
mean "Compare the contents of two text files." is a little plain. You ought to look at Yahoo's home page and
see how they create article titles to grab viewers interested.
You might add a related video or a picture or two to grab readers excited about
what you've written. In my opinion, it might make your website
a little livelier.
My site; Diet Plans for Women to Lose Weight
What's up friends, good paragraph and good arguments commented here,
ReplyDeleteI am actually enjoying by these.
my page - Diet Plans for Women to Lose Weight
Thankfulness to my father who stated to me regarding this web site, this blog is really amazing.
ReplyDeleteFeel free to surf to my page: Diet Plans to Lose Weight