
Originally Posted by
baru_belajar
1. assume i have 255 items in listbox1 and i wanna move 20 items in to
Sample below will "move" last 20 items from list1 to list2 every 1 second until list1 is empty:
Code:
Option Explicit
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 255
List1.AddItem "Item " & i
Next i
Timer1.Enabled = False
Timer1.Interval = 1000 '1 second
End Sub
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
Dim sItem As String
For i = List1.ListCount - 1 To List1.ListCount - 20 Step -1
If i < 0 Then Exit For
sItem = List1.List(i)
List2.AddItem sItem, 0
List1.RemoveItem (i)
Next i
Timer1.Enabled = CBool(List1.ListCount)
End Sub
If you want to move first items instead then you need to modify loop a bit (timer1_timer procedure).