i want to open a txt file (using commondialog) and load it in the list box, the file should be like that:
http://blah.com/123.exe
http://123.com/blah.exe
etc
Printable View
i want to open a txt file (using commondialog) and load it in the list box, the file should be like that:
http://blah.com/123.exe
http://123.com/blah.exe
etc
Code:Dim fn%, tmp$
fn = FreeFile
Open TXTFILE for Input As #fn
Do While Not(Eof(1))
Line Input #fn, tmp
List1.Additem tmp
Loop
Close #fn
hum....... now how about a way to save that list back in a txt file?? i knwo i didnt' asked for it but now i am ^_*
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
Public Sub List_Save(TheList As ListBox, FileName As String)
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Output As fFile
For Save = 0 To TheList.ListCount - 1
Print #fFile, TheList.List(Save)
Next Save
Close fFile
End Sub
thanx to both of you, i used Matt's code because it has the save code too, but thanx to jop too, the only reason i didn't used ur code was cause i was at school on the wrong classroom when i read the msg (that classroom didn't had VB) and when i got home Matt had both code so i used his code