Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file management

Status
Not open for further replies.

TAnselm

Vendor
Mar 10, 2006
791
US
How do you check to see if a data file exists before trying to open it?

This is what I want to do... when the program boots up it will check to see if this is the first time it is run or if a data file already exists. If the file exists it will open and read from it. If not it will go to another portion of the program to gather information from the user and write to a new data file before continuing.
 
Code:
If IO.File.Exists("MyFile.txt") Then
   'Open file and read
Else
   'First time app run...
End If
 
As you can see, I don’t follow Dilbert’s advice :-D
 
nice try but it didn't work...
getting an error on the first line. (if IO.File.Exists ...)
here is my code:

If IO.File.Exists ("c:\test.txt") Then
Open "c:\test.txt" For Input As #1
inputframe_frm.Visible = True
Else
Open "c:\test.txt" For Output As #1
test_frm.Visible = True
End If


 
Not that I think it matters but I'm using visual basic 6.0 and i'm getting run-time error 424; "Object Required
 
It matters.
Please try to search your answer in forum222.

Good luck.
 
Wow, is Visual Basic 6.0 already a dinosaur???

Should I be teaching myself VB.NET?
 
Not in my book.
But Microsoft says that they do not support VB6 anymore (at one point of time, I forgot).

But you can continue using that tool.

Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top