VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 从各方面简化文件检查
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8808, 日期:2000-10-20
Simple file checking from anywhere
By Matthew Kent, mace@pacificcoast.net
To keep my applications running smoothly, I often need to check that certain files exist. So, I注释:ve written a simple routine to make sure they do. Here it is:

Public Sub VerifyFile(FileName As String)
  注释:
  On Error Resume Next
  注释:Open a specified existing file
  Open FileName For Input As #1
  注释:Error handler generates error message with file and exits the routine
  If Err Then
    MsgBox ("The file " & FileName & " cannot be found.")
    Exit Sub
  End If
  Close #1
注释:
End Sub

Now add a button to your form and place the code below behind the "Click" event.

Private Sub cmdVerify_Click()
  注释:
  Call VerifyFile("MyFile.txt")
  注释:
End Sub