This is what I'm doing:
Is there an alternative to this? as VB doesn't seem to like it.Code:Dim count As New Timer
controls.add(count)
Printable View
This is what I'm doing:
Is there an alternative to this? as VB doesn't seem to like it.Code:Dim count As New Timer
controls.add(count)
Look at your question. Do we know what controls is or should we assume something? "VB doesn't seem to like it" doesn't mean much.
What are you trying to accomplish?
VB doesn't like it at all. Timer is not a control!
A timer is a component rather than a control, and the Controls collection can only accept Controls or things derived from Control. Fortunately, this doesn't matter, as there is no good reason to add a timer to a Controls collection. A timer is not contained within anything, but is just a member variable in the form class itself. Since it has no location, or any of the other features of a control, you wouldn't gain in any way by adding it to a collection.
Frankly, I've made that mistake, as well. Something on the toolbar, such as a timer and all controls, gets dragged onto the form. In that way, you are interacting with all of them in a similar fashion, so it is fairly automatic to assume that they are all the same animal in some way.
The designer tricks you into believing that a parent/child relationship exists between a Form and a Component like a Timer. Only controls have a true relationship via the Form's control collection but with Timers and such, the designer adds it to an IContainer implementation which is referenced by nothing more than a private field generated by the designer. Any class that implements IComponent and has a public constructor that takes an IContainer will be added to the IContainer implementation referenced by the designer generated private field of the Form.