timer and button flash

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?bWFydGluMQ==?=

    #1

    timer and button flash

    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


  • rowe_newsgroups

    #2
    Re: timer and button flash

    On May 31, 9:02 am, martin1 <mart...@discus sions.microsoft .comwrote:
    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(ByVa l sender As System.Object, ByVal e As
    System.EventArg s) 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(ByVa l 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

    Comment

    Working...