Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27196

VS 2010 [RESOLVED] a tale of two timers

$
0
0
Hi folks.

I have a form with a label. I want the form to display a message every 5 seconds, and the message to display for 700ms before closing. So I used timer1 with an interval of 5000ms, and timer2 with an interval of 700ms. But the message seems to be displaying every 5 seconds(what I want), but is displayed for 5 seconds(what I don't want). I want the message to display only for 700ms. Where is the problem in the code? Thanks in advance.

Code:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Timer1.Start()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Timer2.Start()
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        If Me.Visible = True Then
            Me.Visible = False
        Else
            Me.Visible = True
            Me.Label1.Text = "Test Message"
        End If
        Timer2.Stop()
    End Sub
End Class


Viewing all articles
Browse latest Browse all 27196

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>