VB Code:
Private Function FindFree_Timer As Integer Dim intIterate As Integer FindFree_Timer = 0 On Error Goto ErrorHandler For intIterate = 1 To Timer1.Ubound Timer1(intIterate).Tag = Timer1(intIterate).Tag Next On Error Goto 0 'FindFree_Timer = 0 since all are loaded Exit Function ErrorHandler: 'Goes here if instance does not exist FindFree_Timer = intIterate Err.Clear End Sub Public Function Assigned_TimerIndex As Integer Dim intRetIndex As Integer intRetIndex = FindFree_Timer If intRetIndex = 0 Then Load Timer1(Timer1.Ubound + 1) Timer1(Timer1.Ubound).Interval = 5000 'Ubound updates Assigned_TierIndex = Timer1.Ubound Else Load Timer1(intRetIndex) Timer1(intRetIndex).Interval = 5000 Assigned_TierIndex = intRetIndex End if End Sub
That should fill up your holes. Admittedly, they won't be in order of creation.... but do you really want to bother with that? In the end, you wont have miore than 32K students being assigned timers anyway.
You can modify the concept to skip over the holes if your iterating through the control array. Either create a list of loaded indices or use On Error Resume Next to ignore the error with unloaded indices.




Reply With Quote