Results 1 to 19 of 19

Thread: Multiple Selection From ListBox

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    403
    Location
    Absolutely beautiful! Many thanks to both gmayor and gmaxey!!


    Only problem left is that when clicking on an option in the ListBox, choosing a single entry is fine. Select another entry too and it will not always pick the correct option, but will put two of the same into TextBox 2. If two options are selected from the ListBox, then two lots of whichever is first in the list order will populate the TextBox.

    Will this have anything to do with where I placed this?

    Dim myArray()   As String
        
        'Redefine list for reason for threat level
        'Select threat level
        'Create list of grades for threat
        myArray = Split("- Select -|High|Medium|Low", "|")
        'Use List method to populate listbox
        ComboBox2.List = myArray
        ComboBox2.ListIndex = 0
        'Use List method to populate listbox
        ComboBox3.List = myArray
        ComboBox3.ListIndex = 0
        'Use List method to populate listbox
        ComboBox4.List = myArray
        ComboBox4.ListIndex = 0
        'Use List method to populate listbox
        ComboBox5.List = myArray
        ComboBox5.ListIndex = 0
        
    lbl_Exit:
        Exit Sub
    End Sub

    This is where I have placed it...

    Private Sub UserForm_initialize()
        
        Dim myArray()   As String
        
        'Define list for threat level
        'Select threat level
        'Create list of grades for threat
        myArray = Split("- Select -|High|Medium|Low", "|")
        'Use List method to populate listbox
        ComboBox2.List = myArray
        ComboBox2.ListIndex = 0
        'Use List method to populate listbox
        ComboBox3.List = myArray
        ComboBox3.ListIndex = 0
        'Use List method to populate listbox
        ComboBox4.List = myArray
        ComboBox4.ListIndex = 0
        'Use List method to populate listbox
        ComboBox5.List = myArray
        ComboBox5.ListIndex = 0
        
    
        
        With TextBox2
            .MultiLine = True
            .ScrollBars = fmScrollBarsVertical
        End With
        ListBox1.List = Split("Requires further investigation|Urgent review|" _
                      & "Manageable risk|For Noting Only", "|")
    lbl_Exit:
        Exit Sub
    End Sub
    Last edited by HTSCF Fareha; 08-24-2020 at 11:10 AM.

Posting Permissions

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