|
-
Oct 27th, 2000, 07:55 PM
#1
Thread Starter
Lively Member
I need to check to see if a file exists.
I'm not home right now, and wanted to check the theory I have......
If I try to OPEN a file for input (txt based), and put in a on-error goto line will this work? I'm not for sure how to write this out exactly though.
Like:
--------
On Error Goto Error1
Open "C:\test.txt" For Input As #1
Close #1
Exit Sub 'found the file - it exists
Error1:
Open "C:\test.txt" For Output As #1
Close #1 'Make the file
-------------
Did I get the theory right, and (if so) is there an easier (better) way to do this?
thanks!
-
Oct 27th, 2000, 09:27 PM
#2
_______
<?>
Not quite
Code:
Private Command1_Click()
On Error Goto Error1: 'this will sent it to Error1
Open "C:\test.txt" For Input As #1
'do whatever
Close #1
'in error one we already have the error so we muct
'react to what the error will be
'file not found is 53
Error1:
If err.Number = 53 then
Msgbox "Sorry, file not fount!"
End IF
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Oct 27th, 2000, 09:28 PM
#3
_______
<?>
I forgot:
If you want to check for the file's existance
If Dir("C:\test.txt") <> "" then MsgBox "File Exists"
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|