Attribute VB_Name = "MyListBox" Attribute VB_Creatable = True Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Compare Database Option Explicit Private WithEvents mlistbox As listbox Public Property Set listbox(lstWhat As listbox) Set mlistbox = lstWhat mlistbox.RowSourceType = "Value list" End Property Public Sub Clear() mlistbox.RowSource = "" mlistbox.Requery End Sub Public Sub Copy(lstWhat As listbox) Dim i As Long If lstWhat.RowSourceType = "Value list" Then mlistbox.RowSource = lstWhat.RowSource Else For i = 1 To lstWhat.ListCount AddItem lstWhat.ItemData(i) Next End If End Sub Public Function RemoveItem(lngIndex As Long) As String Dim objFrom As New StringObj objFrom.Init mlistbox.RowSource objFrom.Del mlistbox.ItemData(lngIndex) mlistbox.RowSource = objFrom.Value Set objFrom = Nothing End Function Public Sub AddItem(ByVal strItem As String, Optional lngIndex) Dim objFrom As New StringObj, objTo As New StringObj Dim i As Integer If IsMissing(lngIndex) Or lngIndex >= mlistbox.ListCount Then If mlistbox.RowSource = "" Then mlistbox.RowSource = strItem Else mlistbox.RowSource = mlistbox.RowSource & ";" & strItem End If ElseIf lngIndex < 1 Then If mlistbox.RowSource = "" Then mlistbox.RowSource = strItem Else mlistbox.RowSource = strItem & ";" & mlistbox.RowSource End If Else objFrom.Init mlistbox.RowSource objTo.Init For i = 1 To lngIndex objTo.Add objFrom.Remove Next objTo.Add strItem If Not objFrom.isEmpty Then objTo.Add objFrom.Value End If mlistbox.RowSource = objTo.Value Set objFrom = Nothing Set objTo = Nothing End If End Sub