"If Exist" command in VB?

bodhran1

Dazed and Confused
Local time
Today, 08:19
Joined
Mar 27, 2002
Messages
43
Hi all,

Here's what I'm trying to do. Can you help me?

I assign a temp file name of "DP01.txt"

If this file already exists on C:\, I'd like to try DP02.txt then DP03.txt ...etc

Once I find an unused number (between 01-99) I'll open it and start writing data to it.

I have the program working fine if I assign a number, but I can't figure out how to search my drive to see if the filename exists already.

TIA

Dave
dpasquino@actechdrives.com
 
Use "DIR"

Look it up in the Help File or Knowledge base. It has an example on how to search for a file and Enumerate through the directory.

If Dir("C:\DP01.txt")="" Then
Msgbox "FILE DOES Not Exist"
ELSE
MSGBOX "FILE Exists"
END IF
 

Users who are viewing this thread

Back
Top Bottom