CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Location
    Highland, CA, USA
    Posts
    10

    Listing Multiselected Items from a Listbox..

    Hello,

    I made a listbox, checkbox style and....


    For i = 0 To lstTest.ListCount - 1
    If lstTest.Selected(i) Then
    MsgBox lstTest.List(i)
    End If
    Next i

    I found a way to show all the people I selected from a list box...through a message box. Let's pretend it's a list of people....

    How would I grab from the listbox, say the names in the list are "joe shmo" and "britney spears" which are the ones I selected and then assign each one to it's own variable? (Maybe a string variable)?

    Thanks.

  2. #2
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Code:
    Dim MyArray() as string
    dim Max as Integer
    For i = 0 To lstTest.ListCount - 1
    If lstTest.Selected(i) Then
       Max =  ubound(MyArray) + 1
       Redim Preserve MyArray(Max)
       MyArray(Max) = lstTest.List(i)
    End If
    Next i
    NOTE: If you use Redim without Preserve, you will lose whatever's already in the array.
    Be nice to Harley riders...

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