从各方面简化文件检查 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