-
How can I populate a listbox with data from a text file? OR How can populate a listbox with multiple columns of data? I want to reference the index of the listbox items.
I thought the syntax List1.additem "c:\list1.txt" would work, but it didn't.
Thanks!
-
Try something like:
Code:
Private Sub Form_Load()
Dim iFile As Integer
Dim sData As String
iFile = FreeFile
Open "C:\List1.txt" For Input As iFile
sData = Input(LOF(iFile), iFile)
Close iFile
While Len(sData)
If InStr(sData, vbCrLf) Then
List1.AddItem Left$(sData, InStr(sData, vbCrLf) - 1)
sData = Mid$(sData, InStr(sData, vbCrLf) + 2)
Else
List1.AddItem sData
sData = ""
End If
Wend
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]