[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

Handle file not found in VB6

I have a situation in a VB6 program in which I want the program to wait for a specific filename to appear in a folder.  I was thinking of having it repeatedly try to open that file, and then put an "on error goto" statement to make it not blow up, and possibly a timer so that it doesn't sit there and spin continually.  The first "on error goto" command works OK, but subsequent calls to it cause it to throw the "file not found" dialog.  So...how do I reset the error handler so that it works for what I need it to do?  TIA.
Sub WaitForFile()
   fIntFile = FreeFile
   
NoFileAvailable:
   Err.Clear
'Handle file not found errors
   On Error GoTo NoFileAvailable


Open strIntFileName For Input As #fIntFile
   
End Sub

Open in new window

0
thomsone
Asked:
thomsone
1 Solution
 
shaydieCommented:
Why not just check for its existence rather than try to open it and generate an error?
something like
if dir(filename) = "" then
0
 
thomsoneAuthor Commented:
Great idea!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now