0

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

4
Contributors
3
Replies
24
Views
3 Years
Discussion Span
Last Post by ling_tj
1

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

Edited by Jx_Man

Votes + Comments
great help :)
0

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
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.