timer and button flash

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, All,

I create 3 buttons in for loop in code like below:

For i= 0 to 2
Dim button as new button
Next

button will flash if button value is 1 using timer, my question is I need to
create 3 timers or 3 button can share one timer?

Thanks,
Martin
 
Hi, All,

I create 3 buttons in for loop in code like below:

For i= 0 to 2
Dim button as new button
Next

button will flash if button value is 1 using timer, my question is I need to
create 3 timers or 3 button can share one timer?

Thanks,
Martin

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To 2
Dim b As New Button()
buttonsToFlash.Add(b)
Me.Controls.Add(b)
b.Top = 30 * i
Next

Dim timer As New Timer()
timer.Interval = 500
AddHandler timer.Tick, AddressOf timer_Tick
timer.Start()

End Sub

Private buttonsToFlash As New List(Of Button)()

Private Sub timer_Tick(ByVal sender As Object, ByVal e As
EventArgs)
For Each b As Button In buttonsToFlash
b.Visible = Not b.Visible
Next
End Sub

End Class

Thanks,

Seth Rowe
 
Back
Top