tags:

views:

22

answers:

1

Hello, I want to detect series items of a listbox and move them to another listbox suppose list items are

book01
book02
book03
book04
book05
apple
mango
pen
ball
packet1
packet2
packet3

here two series packet and book. A timer will auto detect list1 series items and move to list2 book and packet series

A: 

If I correct understand what you mean then this should do the job:

Private Sub MoveItems()
  Dim l As Long

  List2.Clear
  l = 0

  Do While l < List1.ListCount
    If InStr(List1.List(l), "packet") <> 0 Then
        MoveListItem l
    ElseIf InStr(List1.List(l), "book") <> 0 Then
        MoveListItem l
    Else
        l = l + 1
    End If
  Loop

End Sub

Private Sub MoveListItem(idx As Long)
  List2.AddItem List1.List(idx)
  List1.RemoveItem idx
End Sub
pm_2