Results 1 to 5 of 5

Thread: opening a file in a list box

  1. #1

    Thread Starter
    Addicted Member Rudy's Avatar
    Join Date
    Sep 2000
    Location
    BC, Canada
    Posts
    198
    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
    *Rudy^
    Visual Studio 6 Ent. SP5
    Windows 2000 SP4
    Windows XP SP1a

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Addicted Member Rudy's Avatar
    Join Date
    Sep 2000
    Location
    BC, Canada
    Posts
    198
    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 ^_*
    *Rudy^
    Visual Studio 6 Ent. SP5
    Windows 2000 SP4
    Windows XP SP1a

  4. #4
    Guest
    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

  5. #5

    Thread Starter
    Addicted Member Rudy's Avatar
    Join Date
    Sep 2000
    Location
    BC, Canada
    Posts
    198
    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
    *Rudy^
    Visual Studio 6 Ent. SP5
    Windows 2000 SP4
    Windows XP SP1a

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width