Re: multiple timers, error
this is a logical error. u have declared t(5) to be 6 instances of timer control but u have never actually created the instance for the timer. one way u can do it is put a timer in the form and set the index property to 0. then u can load the timers by using
Re: multiple timers, error
thanks how would i then unload t(1)?
Set t(Index) = Nothing
gives me invalid use of object property or something
and also
Load t(1)
how would i make that so its like
If t(1) <> Loaded Then Load t(1)
Re: multiple timers, error
You cannot dynamically create Timer controls and restrict them to the code alone. Timer is not a class, it is a Control, the only way you can create one is to add it to the form.
VB Code:
Dim t(5) As Timer
Private Sub Form_Load()
Dim i As Long
For i = 0 To 5
timer(i) = Me.Controls.Add("VB.Timer", "timer_" & CStr(i))
Next i
...
Re: multiple timers, error
from msdn on control array
Quote:
Events in the Control Array Application
Next, you need to add the event procedures for the option buttons and command buttons. Start by adding the form declaration:
The Click event procedure is shared by all the option buttons:
VB Code:
Private Sub optButton_Click (Index As Integer)
picDisplay.BackColor = QBColor(Index + 1)
End Sub
New option buttons are added by the Click event procedure for the Add command button. In this example, the code checks that no more than ten option buttons are loaded before the Load statement is executed. Once a control is loaded, its Visible property must be set to True.
VB Code:
Private Sub cmdAdd_Click ()
If MaxId = 0 Then MaxId = 1 ' Set total option
' buttons.
If MaxId > 8 Then Exit Sub ' Only ten buttons
' allowed.
MaxId = MaxId + 1 ' Increment button count.
Load optButton(MaxId) ' Create new button.
optButton(0).SetFocus ' Reset button selection.
' Set new button under previous button.
optButton(MaxId).Top = optButton(MaxId - 1)._
Top + 400
optButton(MaxId).Visible = True ' Display new
' button.
optButton(MaxId).Caption = "Option" & MaxId + 1
End Sub
Option buttons are removed by the Click event procedure for the Delete command button:
VB Code:
Private Sub cmdDelete_Click ()
If MaxId <= 1 Then Exit Sub ' Keep first two
' buttons.
Unload optButton(MaxId) ' Delete last button.
MaxId = MaxId - 1 ' Decrement button count.
optButton(0).SetFocus ' Reset button selection.
End Sub