-
Hi guys
I have the following function that reads the contents of one of my files. However, I have hundreds of files that I want to read individually. How do I put all the .txt files that I have in my folder into an array and put them through this function????
Thanks for any help.
JK
Code:
Public Function Opening_Files_For_Reading()
Dim inputfile As String
inputfile = "D:\Orator\Outgone\00007629000003.txt"
'***************************************'
'Input the file ---- into a string named TempFile'
'***************************************'
TempFile = "" 'initialise tempfile
Open inputfile For Input As #1
Do While Not EOF(1) ' Check for end of file.
Line Input #1, GenFileText ' Read line of data.
TempFile = TempFile & GenFileText 'increment the temporary string with the file data
MsgBox GenFileText
Loop
Close #1
End Function
-
Heh, yeah. I was looking at my code. but he asked for an array, so I gave it to him :) Though you could easily just slap in the text file parsing code in the for ... each loop with minimal problems. I do have to admit that I hadn't tested my code ... but I think it'll work ;)
-
Cheers guys
Thanks a lot for the help guys.
paulw, what I'm trying to do when I finish here is pass the file contents into a parsing routine which will send the data up to a database.
-
You might be more efficient if you open up the database connection and read the data in in one go. If the files are small, there may well be several in the buffer.
Cheers,
Paul.
-
Thanks a lot for the input.
There are several hundered files in the folders and what I need to do is actually place a timestamp on each file that I parse in order to eliminate the possibility to duplictes in the database.
Any suggestions on how I might do this, more efficiently??
Thanks again,
Your help is really appreciated
JK
-
-
...and to get it:
MsgBox FileDateTime("MYFILE")