the following statements open txt file and read it : - Dim f As Integer
-
f = FreeFile
-
Open App.Path & "\xx.txt" For Input As #f
-
Actually, they don't. They just open it. You haven't started reading it yet.
...
i want if the program not find file,i want to execute next statement without show error. what is the code use to ignore that error.
You could do it something like this...
- Dim f As Integer
-
f = FreeFile
- On Error Resume Next ' If error occurs, continue with next statement.
-
Open App.Path & "\xx.txt" For Input As #f
- On Error Goto 0 ' Turn off error handling.
Then the question arises, of course, do you want to
know that the file was not found?
I believe it would generally be considered better technique to check first that the file
does exist, and only fall back on error handling if an actual problem crops up, such as being unable to open it.