CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    1

    Post Select Items In Listbox and add them to string

    Hi Guys,

    I need some help with a little code i am working in VB 2010 and making a program for work, i am almost finished but i am having trouble getting all the items that are in a list box and adding them to a string. So it needs to select all items in that list box i have been able to get the highlighted item and add it to a string but cannot get ever item to add or even highlight to that string.

    Any help would be greatly appreciated.

    Thanks in advance.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: Select Items In Listbox and add them to string

    [ Moved ]

    perhaps something like this might help :

    Code:
    Dim SelItems(ListBox1.SelectedItems.Count - 1) As String 'Create Array With Selected Items
    
      ListBox1.SelectedItems.CopyTo(SelItems, 0) 'Copy All Selected Items To Array
    
      Dim AllItemsInOneString As String = String.Join(" ", SelItems) 'Join All Array Items To One String Separated By A Space
    Oh, and welcome to the forums!

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