SuperNovaa41 SuperNovaa41 - 1 year ago 81 Question

How do I make an event happen every x seconds? VB.NET [Solved]

I'm trying to create make an event call back every x seconds, I've done some research but I couldn't find any info on doing this function.

Does anyone know how I can do this in VB.NET?

Thanks in advance!

Answer Source

How do I make it add one to my counter every 10 seconds?

Public Class Form1

    Private Counter As Integer = 0

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Label1.Text = Counter.ToString
        Me.Timer1.Interval = TimeSpan.FromSeconds(10).TotalMilliseconds
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Counter = Counter + 1
        Label1.Text = Counter.ToString
    End Sub

End Class
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download