Solved

Handle file not found in VB6

Posted on 2011-09-20
2
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

734 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