CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Location
    Michigan, USA
    Posts
    29

    whiles, files, and listboxes

    I'm trying to get a list of items in a text file to be displayed in a listbox control. unfortunatly I don't know exactly how. This is what I have and it doesn't do it. By the way if it makes a difference, the file could hold nothing before #endlist#

    'loading items from file into array
    While buffer <> "#endlist#"
    input filenum, buffer
    list(i) = buffer
    i = i + 1
    Wend

    'from the array into the listbox
    While buffer <> "" and i <= listMax
    lstBox.AddItem(list(i))
    i = i + 1
    Wend



    these are both just snippets of code, they DO NOT come directly after each other
    now all this does is give me a headache and displays the "#endlist#" in the listbox. help...


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: whiles, files, and listboxes

    Here is an example how to put every string from the text file to listbox
    Open "c:\temp\temp.txt" For Input As #1 'to read from
    Do While Not EOF(1)
    Line Input #1, sLine
    List1.AddItem sLine
    Loop
    Close #1


    'You might want to extract some data from sLine. You can do it before adding to the listbox


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured