Hi
I'm really stuck on this: I want to loop through the timers on my form, and even better to be able to direct cast them from a name.
What I tried:
For Each ctrl As Control In Me.Controls
If (TypeOf ctrl Is Timer) Then
cControl.Enabled = False
End If
But get this error: "Expression of type 'System.Windows.Forms.Control' can never be of type 'System.Windows.Forms.Timer'. "
That method works perfectly for looping through buttons, textboxes... but not timers
Another problem is trying to DirectCast from a name to a Control. It will (again) not work with Timers.
I Tried:
Dim ctrl As Timer = Directcast("Timer1", Timer)
If anyone could please advise me on how to:
Loop through Timers
and how to reference timers
I would really appreciate it
I'm really stuck on this: I want to loop through the timers on my form, and even better to be able to direct cast them from a name.
What I tried:
For Each ctrl As Control In Me.Controls
If (TypeOf ctrl Is Timer) Then
cControl.Enabled = False
End If
But get this error: "Expression of type 'System.Windows.Forms.Control' can never be of type 'System.Windows.Forms.Timer'. "
That method works perfectly for looping through buttons, textboxes... but not timers
Another problem is trying to DirectCast from a name to a Control. It will (again) not work with Timers.
I Tried:
Dim ctrl As Timer = Directcast("Timer1", Timer)
If anyone could please advise me on how to:
Loop through Timers
and how to reference timers
I would really appreciate it