Dear All,

I have a listbox with various items like : Ali, Aslam, Akram, Jone, Mikle, Ebrahim etc.
Now I have to select more than one items like : Jone, Aslam, Akram in a Textbox.

Could anyone let me know the code.

Rashid

Recommended Answers

All 3 Replies

Set MultiSelect = 2 - Extend in Listbox properties.
Press "Ctrl" while you select items.

Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
    If List1.Selected(i) Then
        Text1.Text = Text1 + List1.List(i) + ","
    End If
Next

End Sub
commented: great help :) +3

just improvement from Jx_man's code

Dim i As Integer
For i = 0 To List1.ListCount - 1
    If List1.Selected(i) Then
    '    Text1.Text = Text1 + List1.List(i) + ","
        If Text1.Text = "" Then
            Text1.Text = List1.List(i)
        Else
            Text1.Text = Text1 + "," + List1.List(i)
        End If
    End If
Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.