VB编程技巧:比较两个文件-钱玉炜
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> 综合其它


VB编程技巧:比较两个文件

发表时间:2008/5/21 8:53:29 评论(0) 浏览(5774)  评论 | 加入收藏 | 复制
   
摘 要:VB编程技巧:比较两个文件
正 文:
比较两个文件
Function CompFile(F1 As String, F2 As String) As Boolean
Dim issame As Boolean
Open F1 For Binary As #1
Open F2 For Binary As #2
issame = True
If LOF(1) <> LOF(2) Then
issame = False
Else
whole& = LOF(1) \ 10000 'number of whole 10,000 byte chunks
part& = LOF(1) Mod 10000 'remaining bytes at end of file
buffer1$ = String$(10000, 0)
buffer2$ = String$(10000, 0)
start& = 1
For x& = 1 To whole& 'this for-next loop will get 10,000
Get #1, start&, buffer1$ 'byte chunks at a time.
Get #2, start&, buffer2$
If buffer1$ <> buffer2$ Then
issame = False
Exit For
End If
start& = start& + 10000
Next
buffer1$ = String$(part&, 0)
buffer2$ = String$(part&, 0)
Get #1, start&, buffer1$ 'get the remaining bytes at the end
Get #2, start&, buffer2$ 'get the remaining bytes at the end
If buffer1$ <> buffer2$ Then
issame = False
End If
Close
CompFile = issame
End Function

Access软件网交流QQ群(群号:198465573)
 
 相关文章
VB编程技巧:利用API 使Text框只读  【UMVSOFT整理  2008/5/16】
VB编程技巧:表或查询是否存在  【UMVSOFT整理  2008/5/20】
VB编程技巧:移动文件到回收站  【UMVSOFT整理  2008/5/21】
VB编程技巧:比较两个文件  【UMVSOFT整理  2008/5/21】
常见问答
技术分类
相关资源
文章搜索
关于作者

钱玉炜

文章分类

文章存档

友情链接