> I have a listbox that I want to populate with information from a text
file.
For each index in the listbox, I want to load the next line of the
text file, until there are no more lines. I have the code to open and read
each line from the text file, but I cannot figure out a way to read a line,
put it into the listbox, then go to the next line and repeat the process.
I know it will have to use a For... Next loop, but can't get the
configuration right. Any help would be greatly appreciated!
Usually it is a good idea to post the code that is not working as you
expect (or that you have so far). That way, we can adapt our answers to
your style of programming or even make suggestions of ways we might
approach the problem differently. Without seeing your code, the best we
can do is give you code and hope it makes sense to you or, if it
doesn't, that you will try and read up on the parts that are unfamiliar
to you.
Dim FF As Long
Dim LineOfText As String
FF = FreeFile
Open "c:\temp\Bi-Weekly Work Schedule (2009).txt" For Input As #FF
Do While Not EOF(FF)
Line Input #FF, LineOfText
' If test makes sure you don't add a blank line
If Len(LineOfText) Then List1.AddItem LineOfText
Loop
Close #FF
Rick - MVP