Results 1 to 19 of 19

Thread: [RESOLVED] Saving Items in listbox

Threaded View

  1. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2009
    Posts
    435

    Re: Saving Items in listbox

    Quote Originally Posted by jmcilhinney View Post
    Assuming that the ListBox contains just Strings:
    vb.net Code:
    1. Dim items(Me.ListBox1.Items.Count - 1) As String
    2.  
    3. Me.ListBox1.Items.CopyTo(items, 0)
    4. IO.File.WriteAllLines("file path here", items)
    or with LINQ:
    vb.net Code:
    1. IO.File.WriteAllLines("file path here", _
    2.                       Me.ListBox1.Items.Cast(Of String)().ToArray())
    To reload:
    vb.net Code:
    1. Me.ListBox1.Items.AddRange(IO.File.ReadAllLines("file path here"))
    I would like to store some other things in the Text File, how do I get it to only read part of the file?
    Reloading it doesnt work. I put the code in my Formloading, and nothing happened. I checked the Text File and there was text
    Last edited by werido; Oct 19th, 2009 at 09:11 PM.

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