I'm trying to enable a timer from a SerialPort_DataReceived event. I can see that the timer is enabled, but the event does not fire.
It's rather simple, but I need some help understanding why it doesn't run the code in TimerWait_Tick.
Thanks,
Dave
Private WithEvents Dave As New System.IO.Ports.SerialPort
Private WithEvents timerWait As New Timer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
timerWait.Enabled = False
Dave.BaudRate = "9600"
Dave.StopBits = IO.Ports.StopBits.One
Dave.PortName = "COM1"
Dave.DataBits = 8
Dave.Open()
Button1.Enabled = False
End Sub
Private Sub Dave_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Dave.DataReceived
timerWait.Interval = 200
Me.timerWait.Enabled = True
End Sub
Private Sub TimerWait_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timerWait.Tick
If IsNumeric(Label1.Text) Then
Label1.Text = Val(Label1.Text) + 1
Else
Label1.Text = "0"
End If
End Sub
It's rather simple, but I need some help understanding why it doesn't run the code in TimerWait_Tick.
Thanks,
Dave
Private WithEvents Dave As New System.IO.Ports.SerialPort
Private WithEvents timerWait As New Timer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
timerWait.Enabled = False
Dave.BaudRate = "9600"
Dave.StopBits = IO.Ports.StopBits.One
Dave.PortName = "COM1"
Dave.DataBits = 8
Dave.Open()
Button1.Enabled = False
End Sub
Private Sub Dave_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Dave.DataReceived
timerWait.Interval = 200
Me.timerWait.Enabled = True
End Sub
Private Sub TimerWait_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timerWait.Tick
If IsNumeric(Label1.Text) Then
Label1.Text = Val(Label1.Text) + 1
Else
Label1.Text = "0"
End If
End Sub