
How to read file contents into list box.
Quote:
> I need to read the contents of a text file into a list box.
>The file contains names, one per line.
> I have a text box that a user enters a new name into and this in turn
>will add the name to the list in the list box via a command button.
> I can easily load the file contents into a text box, but then I
>am unable to allow additional names to be entered. On the other hand,
>if I use a list box, I can update names into the box but the file
>contents will not load into the list box, it is initially blank.
> Perhaps I am unaware of the proper coding to allow both of these
>to work together. I would very much appreciate any help that can be
>offered. Thanks, Sean.
If I'm Understanding you correctly, you want code similar to the
following:
f=freefile
Open "Filename.txt" for input as #f
Do while not eof(f)
Line Input #f, strPersonName
List1.AddItem strPersonName
Loop
Close f
I'm assuming here that you are reading from a text file.
Regards,
Jon Brierley