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

VS 2010 [RESOLVED] stopwatch and timer

$
0
0
Hi folks.

I want a stopwatch to start as soon as the form is loaded, and after 3 seconds, a message box displays "Hello World". But why isn't the message box being displayed? Thanks in advance.

Code:

Public Class frmBreak
    Dim sw1 As New Stopwatch
    Private Sub bttnClose_Click(sender As System.Object, e As System.EventArgs) Handles bttnClose.Click
        Me.Close()
    End Sub

    Private Sub frmBreak_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        sw1.Start()
    End Sub

    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Dim ts1 As TimeSpan = sw1.Elapsed
        Timer1.Interval = 1000
        If ts1.Seconds = 3 Then
            sw1.Stop()
            MsgBox("Hello World")
        End If
    End Sub
End Class


Viewing all articles
Browse latest Browse all 27072

Trending Articles



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