Solved

Handle file not found in VB6

Posted on 2011-09-20
2
213 Views
Last Modified: 2012-05-12
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
Comment
Question by:thomsone
2 Comments
 
LVL 7

Accepted Solution

by:
shaydie earned 500 total points
ID: 36569651
Why not just check for its existence rather than try to open it and generate an error?
something like
if dir(filename) = "" then
0
 

Author Closing Comment

by:thomsone
ID: 36569683
Great idea!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now