i/o process multiple text files

I want to write a program to do some simple search & replace type stuff on text files located within a single directory.
Assuming that the NUMBER of files to process will vary, and the NAMES of these files will vary, what would be the best way to get the actual "program loop" to automatically select and start processing, and when it completes and closes the first file, move on to the second, third, etc. until all files have been done?
I don't need help on the actual Search & Replace, I guess I'd like to see a code example of how the program could read the names of the files in "directory x" and then loop through all files until it has performed the S&R (or any other) function on every file it finds in "directory x".  

nascar_3Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hesCommented:
Dim FileToOpen As String
Dim MyDir as String
Dim FileNo
MyDir = "Path & Dir Name\"
FileToOpen = Dir(MyDir & "*", vbNormal)
While FileToOpen <> ""
  FileNo = FreeFile
  Open MyDir & FileToOpen for Input as #FileNo

   'Your code here

  Close #FileNo
  FileToOpen = Dir
Wend
0
moterkCommented:
'TxtPath folder with text files

if right(TxtPath,1)<>"\" then TxtPath=TxtPath+"\"

TxtFile$=Dir(TxtPath & "*.txt")
do until TxtFile$=""
    ' add open, read, process, and
    ' close stuff here
    TxtFile$=Dir
loop
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erick37Commented:
Don't forget to put a DoEvents statement in the loop and a Cancel option.
0
nascar_3Author Commented:
Both Hes & Moterk's Answers are very similar.
I did try Hes' code FIRST, but for some (unexplored) reason, I could not get it running right away, and after several failed attempts to fix it, I switched to Moterk's code and got it running immediately.
Moterk's was also shorter and to-the-point, so....
points given to Moterk!
Thanks!

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.