D
derSchweiz
I have an application that requires the use of a timer and I have created
the timer object globally:
Private t As New System.Timers.Timer(4000)
And I have a button that that triggers an event handler:
Private Sub myButton(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
t.Enabled = True
AddHandler t.Elapsed, AddressOf TimerFired
End Sub
Which triggers:
Private Sub TimerFired(ByVal sender As Object, _ByVal e As
System.Timers.ElapsedEventArgs)
MsgBox(commandID)
commandID = commandID + 1
If commandID = 7 Then
t.Enabled = False
t.Stop()
t.Close()
commandID = 0
isFirstStart = False
End If
End Sub
The first the time button gets clicked, the TimerFired method fires every 4
seconds, it works great the first time, however on the second time it goes
like
Fire Fire... 4 seconds.. Fire fire... 4 seconds... fire fire
On the third time it will go like:
fire fire fire... 4 seconds fire fire fire...
How can I make it so that it will go like
fire... 4 seconds... fire... 4 seconds... fire 4 seconds etc...
each time I press the button?
p.s Please explain as simply as possible, this is my first time programming
in VB.
Thanks for any input
the timer object globally:
Private t As New System.Timers.Timer(4000)
And I have a button that that triggers an event handler:
Private Sub myButton(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
t.Enabled = True
AddHandler t.Elapsed, AddressOf TimerFired
End Sub
Which triggers:
Private Sub TimerFired(ByVal sender As Object, _ByVal e As
System.Timers.ElapsedEventArgs)
MsgBox(commandID)
commandID = commandID + 1
If commandID = 7 Then
t.Enabled = False
t.Stop()
t.Close()
commandID = 0
isFirstStart = False
End If
End Sub
The first the time button gets clicked, the TimerFired method fires every 4
seconds, it works great the first time, however on the second time it goes
like
Fire Fire... 4 seconds.. Fire fire... 4 seconds... fire fire
On the third time it will go like:
fire fire fire... 4 seconds fire fire fire...
How can I make it so that it will go like
fire... 4 seconds... fire... 4 seconds... fire 4 seconds etc...
each time I press the button?
p.s Please explain as simply as possible, this is my first time programming
in VB.
Thanks for any input