How to add different options in several lines of a TextBox by selecting from ListBox VB6?

0

I'm new to Visual Basic 6 and I have a question, I've been trying for a while to make a ListBox that "prints" the selection of the list in a TextBox and I could not find the solution until today with one possible I created a command button with the following parameters:

Private Sub Command6_Click()
For i = 0 To List1.ListCount - 1
    If List1.Selected(i) Then
    Text5.Text = List1.List(i)
    End If
Next
End Sub

Having a ListBox identified as List1 and the text box where I want to "print" called Text5 The question is that I need to select multiple options and that these (again) are "printed" in a separate line according to I go selecting and adding with the button different items in the list. Any suggestions?

As an extra in the properties of Text5 is set to accept multilines and List1 to support multiple selection.

In summary, I want to make a multiple selection in a text box independent of the list. Because it's simple, I'm working with an Access database to be able to store the information, but I need to add multiple information in a single Field and I'm not allowed at least with VB6.

Any suggestions to supplement the code or another method is acceptable, THANK YOU!

    
asked by Dєηyη Crawford 18.10.2017 в 15:44
source

1 answer

1

Good Dєηyη,

You can use the property SelectedItems of ListView to get only the selected rows in the following way:

For Each row As String In List1.SelectedItems
    'Imprimo todas las selecciones con salto de línea en el textBox'
    Text5.Text += row & Environment.NewLine
Next
    
answered by 18.10.2017 / 15:54
source