none
Start timer to another form RRS feed

  • Question

  • Unable to start timer to another form.

    Both form (form1 and form2) running same at the  time, 

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    Timer1.Enable = True
    Timer1.Start()

          Dim f As New Form
            f = form2
            f.ShowDialog()

    End Sub


    than form1 timer1 start and after 20 sec I want start form2.timer2 from form1.

    Private Sub Timer1_Elapsed(sender As System.Object, e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
           
    form2.timer2.enable = true
    form2.timer2.start()

    End Sub

    but nothing start,,any help please

    Saturday, March 30, 2019 9:07 AM

All replies

  • Hi,

    try the code:

    Public Class Form1
        Dim f2 As New Form2
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Timer1.Enabled = True
            Timer1.Start()
    
            f2.Show(Me)
    
        End Sub
    
        Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
            f2.Timer2.Enabled = True
            f2.timer2.start()
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Saturday, March 30, 2019 9:34 AM