Hi guys, this is my first post so please be gentle 😀
I`m having problems with the timer control that I hope people can help me out with.
Basically, i`m creating the timer control at runtime (full code at end of post) and it just will not work and I don’t know why!
I’ve compared it to code used to control a design-time timer and they are practically identical (bar the timer generation code obviously). I’ve looked at some tutorials for creating timers at runtime and my code seems almost identical to theirs, I don’t know what I`m doing wrong!
Here’s the code:
inherits System.Windows.Forms.form
Dim tTimer As System.Timers.Timer
Sub Form2Load(ByVal sender As Object, ByVal e As EventArgs)
tTimer=New System.Timers.Timer
ttimer.interval=1000
tTimer.Enabled=false
AddHandler tTimer.elapsed, AddressOf TimerFired
End Sub
Private Sub TimerFired(ByVal sender As Object, _
ByVal e As System.Timers.ElapsedEventArgs)
label1.Text = now.ToLongTimeString.tostring()
End
Sub
Sub Button1Click(ByVal sender As Object, ByVal e As EventArgs)
msgbox(tTimer.interval)
tTimer.Enabled=true
End Sub
Hope someone can help before I damage the computer!