Results 1 to 2 of 2

Thread: Selecting next item in list using a timer

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    15

    Selecting next item in list using a timer

    My program is selecting an item in a list and exectuing code. This is for entering chatrooms. You add the names of a few different chatrooms and click cycle. This code then cycles through the list until it finds a room on your list that isnt' full.

    Now is what i want to do is cycle the room on a 5 min timer. I have the code for cycle every 5 minutes.

    My problem is i want the cycle to start at the last room it entered. So if it entered the first room on the list, after 5 minutes i want to start to cycle at the 2nd room on the list and so on.

    Here is the code i currently have

    code:

    StopBust = False
    Do: DoEvents

    inRoom = BustPrivate(List2.List(0))
    If inRoom = False Then
    inRoom = BustPrivate(List2.List(1))
    End If
    If inRoom = False Then
    inRoom = BustPrivate(List2.List(2))
    End If
    If inRoom = False Then
    inRoom = BustPrivate(List2.List(3))
    End If
    If inRoom = False Then
    inRoom = BustPrivate(List2.List(4))
    End If
    Loop Until (inRoom = True) Or (StopBust = True)

    end code:

  2. #2
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    416
    make Timer1 interval = 60000 (1 minute)

    VB Code:
    1. Private Sub Timer1_Timer()
    2.     Dim i As Long
    3.     Static mins As Long
    4.     Static lngLastRoom As Long
    5.    
    6.     If mins = 4 Then
    7.         mins = 0
    8.        
    9.         If lngLastRoom = List2.ListCount - 1 Then lngLastRoom = -1
    10.        
    11.         Do: DoEvents
    12.             For i = lngLastRoom + 1 To List2.ListCount - 1
    13.                 If StopBust Then Exit Do
    14.                
    15.                 If BustPrivate(List2.List(i)) Then
    16.                     lngLastRoom = i
    17.                     Exit Do
    18.                 End If
    19.             Next i
    20.         Loop
    21.     Else
    22.         mins = mins + 1
    23.     End If
    24. End Sub
    Last edited by Eras3r; Jun 18th, 2003 at 04:07 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width