how would you read each line of a file into a seperate element of a listbox?
how could you delete the first 10 characters from a string?
Printable View
how would you read each line of a file into a seperate element of a listbox?
how could you delete the first 10 characters from a string?
1. Try using Line Input
2. str = Right(str, Len(str) - 10)
Q1: (Example)
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$
TheList.AddItem TheContents$
Loop Until EOF(fFile)
Close fFile
End Sub
Usage
Call List_Load(List1, "C:\myfile.txt")