-
How could you import a text file into a listbox where each line in the textfile is a new listbox entry?
-
Code:
Dim ff as integer,buffer as string
ff=freefile
open yourfile for input as ff
line input #ff,buffer
list1.additem buffer
close ff
just make sure yourfile string exist and listbox list1 is there
-
Code:
Open "file.txt" For Input As #1
While EOF(1) = 0
Input #1, s
List1.AddItem s
Wend
Close 1
D!m
-
Try this:
Code:
Public Sub List_Load(TheList As ListBox, FileName As String)
On Error Resume Next
Dim TheContents As String
Dim fFile As Integer
fFile = FreeFile
Open FileName For Input As fFile
Do
Line Input #fFile, TheContents$
Call TheList.Additem (TheContents$)
Loop Until EOF(fFile)
Close fFile
End Sub
Usage:
Call List_Load(List1, "C:\file.txt")
-
Thanks. It worked. Acutally, I used "Matthew Gate"'s. Thanks anyways.