Code Snippet "VBA allgemein"
Elemente zwischen zwei Listbox-Controls hin- und herschieben
Achtung: Lösung ohne Multiselect
'Formular initialisieren
Sub startFrm()
frm1.lst1.AddItem ("Silvia")
frm1.lst1.AddItem ("Max")
frm1.lst1.AddItem ("Franz")
frm1.lst1.AddItem ("Caroline")
frm1.Show
End Sub
'Von linker zu rechter Liste
Private Sub btn1_Click()
If frm1.lst1.ListCount > 0 Then
frm1.lst2.AddItem frm1.lst1
frm1.lst1.RemoveItem (frm1.lst1.ListIndex)
frm1.btn2.Enabled = True
End If
If frm1.lst1.ListCount = 0 Then
frm1.btn1.Enabled = False
End If
End Sub
'Von rechter zu linker Liste
Private Sub btn2_Click()
If frm1.lst2.ListCount > 0 Then
frm1.lst1.AddItem frm1.lst2
frm1.lst2.RemoveItem (frm1.lst2.ListIndex)
frm1.btn1.Enabled = True
End If
If frm1.lst2.ListCount = 0 Then
frm1.btn2.Enabled = False
End If
End Sub