Good colleagues, it turns out that I am making a program MS Visual Basic
where I have a checklistbox that is filled from a combobox , that depending on what I choose in the combobox , the list is generated in the checklistbox when I click on a button, what I want to do now is that what I select in the checklistbox takes the names and puts them in a separate listbox that I have, is it possible to do this with a cycle? How could I do it? I attached an image of my form.
Generate list button code:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
If comboescalafon.SelectedIndex = 0 Then
lista.Items.Add("kevin")
lista.Items.Add("jeison")
ElseIf comboescalafon.SelectedIndex = 1 Then
Button2.Enabled = True
lista.Items.Add("pablo")
lista.Items.Add("andres")
lista.Items.Add("douglas")
lista.Items.Add("chepo")
ElseIf comboescalafon.SelectedIndex = 2 Then
Button2.Enabled = True
lista.Items.Add("caralos")
lista.Items.Add("camila")
lista.Items.Add("jose")
lista.Items.Add("estela")
lista.Items.Add("harold")
lista.Items.Add("jhon")
ElseIf comboescalafon.SelectedIndex = 3 Then
Button2.Enabled = True
lista.Items.Add("felipe")
ElseIf comboescalafon.SelectedIndex = 4 Then
Button2.Enabled = True
lista.Items.Add("juan")
lista.Items.Add("manuel")
lista.Items.Add("gers")
ElseIf comboescalafon.SelectedIndex = 5 Then
Button2.Enabled = True
lista.Items.Add("juan")
lista.Items.Add("daniel")
ElseIf comboescalafon.SelectedIndex = 6 Then
Button2.Enabled = True
lista.Items.Add("alejandro")
ElseIf comboescalafon.SelectedIndex = 7 Then
Button2.Enabled = True
lista.Items.Add("homero")
lista.Items.Add("maguie")
lista.Items.Add("lissa")
ElseIf comboescalafon.SelectedIndex = 8 Then
Button2.Enabled = True
lista.Items.Add("bart")
End If
End Sub
I would like to add the functionality that I mentioned in the add button that is in my form.
Basically what you would do is do a for to retrieve all the data you have selected and then put them in the list (list1).
Change that name to the one you have for your ListBox and it should work.
Logically you have to put this code in the button you use to load your list. (Add button)
I hope it helps you