Firstly, im not sure if this is the correct location for a VBA question?
Please move if necassary.

This is my first major project using VBA - Ive previosuly used vb.net quite alot, and still adjusting to understand both, and the differences.

My question is:
I have a folder with at times none, and at others up to 10-20 .txt files.
i want to loop through each file, and read each line from the file.
I have predefined variables that i want to asssign each of these lines (according to the order of lines read)
But im not sure how to read the file line by line.
I did a quick Google search and found that if use:

Open (*FILENAME*) For Input As File
While Not EOF(File)
Line Input #File, textofline

Then it would do what i wanted, but i cant specify the name of the file, and only that it can be named:
"Serial_*.txt"
The asterisk being any number greater than one (*sigh*)

Is there a way i can loop through the files in the designated folder. and read them one by one, after which i use the variables that are assigned by each line of the text file, to input into my spreadsheet.

SOrry if this is confusing, but im stuck :(

Regards
James

I worked this out, if anyone would like to see the code, just let me know.

Regards
Gobble

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.