Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: List boxes

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is it possible to create a list box that allows you to make multiple selections and can return information associated with those selected items to a table or something? I can get it to work when the Selection Type is 'single', but nothing seems to happen when it's changed to 'multi' or 'extend'.

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I had the same problem. The problem that I came across was when you select multi in your properties, then theres no value. I wasnt able to get help on this question, so I reconfigured how I let the user select a choice. Unfortanatly I had to keep the property to single so there was a value! I wonder how else this could of been done?

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Do you mean that it won't let you select more than one item? Or after they're selected you can't do something with the selections? Is the listbox on a form?

    Dave

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The VBE help says:
    "When the MultiSelect property is set to Extended or Simple, you must use the list box's Selected property to determine the selected items. Also, the Value property of the control is always Null.

    The ListIndex property returns the index of the row with the keyboard focus."

    Which leads me to believe that you have to use the listindex property rather than the value property to return anything.

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Posts
    255
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Okay, I was wrong. What you have to do is use the Selected property to find which items in the list box were selected (the selected property returns true or false) and then use the list property of the list box to return the value. I wrote this code to print the values from a list box (lstListBox) with 6 values on a label. The multiselect property of the list box is set to extend. This code runs off a command button.

    Private Sub cmdPrintListSelection_Click()
    Dim n As Integer
    Dim strItem As String

    For n = 0 To 5
    If lstListBox.Selected(n) = True Then
    strItem = strItem & " " & lstListBox.List(n)
    lblPrintList.Caption = strItem
    End If
    Next n
    End Sub

    It will print all of the selected items on the label.

    I hope that helps.

    Dave

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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