VB.NET Timer - Add Tick Event At Runtime

By James J

Code for add timer & add tick event & display current timer in label

Private Sub MyNewTimer()
        
Dim Timer1 As New Timer()
        
AddHandler Timer1.Tick, AddressOf Timer1_Tick
        Timer1.
Interval = 1000
        Timer1.
Start()
End Sub


Private Sub Timer1_Tick(ByVal obj As Object, ByVal e As EventArgs)
'Display current time in lable...
        lblNowDateTime.
Text = Date.Now.ToString
End Sub


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

'Call here function...
        MyNewTimer()
End Sub

VB.NET Timer - Add Tick Event At Runtime  (3592 Views)