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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DIR Function not working as expected

Status
Not open for further replies.

TheFitz

Programmer
Joined
Dec 18, 2003
Messages
140
Location
GB
Hi, I seem to be having a problem with the DIR function. I have written code similar to below:

Code:
strFile = DIR("C:\*.csv",vbnormal)
intCounter = 0

Do while strfile <> ""

  {Do Stuff including call other functions}
    
  If intCounter = 0 Then
  Else
    strFile = Dir
  End If
    
  intCounter = intCounter + 1

Loop

The {Do Stuff} part calls separate functions which write output to files and collectes various file properties using the FileSystemObject.

As you may notice, the first pass will not do anything with the first file, this is so that the first pass writes headers to the output file. The second pass writes info for the first file correctly.

The third pass on the do...loop should then pick up the second file when the DIR command is issued again, however this doesn't seem to be working and I'm getting an empty string returned (i.e. "") and therefore the do...loop is dropping out.

Has anyone come across this, and anyone got any suggestions on how to get round it?

Many thanks for your help in advance,

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
Oooppss!! Stupid coding! My fault.

Thanks if you were looking into this.

Fitz
Did you know, there are 10 types of people in this world:
* Those who understand binary
and
* Those who Don't!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top