|
-
November 10th, 1999, 06:01 PM
#1
How can I tell if a file was opened sucessfully?
Hello there!
I know how to open, write to, and close a file in visual basic, but how can I tell if a file was opened sucessfully?
If there's an error opening the file, I would like to display a message box indicating so.
Thanks in advance!
Matt
-
November 11th, 1999, 02:45 AM
#2
Re: How can I tell if a file was opened sucessfully?
errors upon opening a file will trap a runtime error:
on error goto errhandler
dim hFile as integer
hFile = freefile
' the following will raise an error
open "yourfile" for input as #hFile
' if we arrived here, the file was opened successfully
...
exit sub
errhandler:
msgbox err.number & " " & err.description
end sub
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
|