急救!关于如何判断串口接受到的字符在一段时间内有没有变化?
我通过串口时时接受到一串字符,字符串中包含S00或S11 ,S 是特征字符。串口通信已实现。 现在我要实现的功能是:每隔5秒钟判断特征字符S后面的数字有没有变化?如没有变化的话,输出“系统有故障”
怎么修改我的代码? 谢谢
Dim Sy2 As String
Dim sy3 As String
Dim sy4 As String
Private Sub process1()
Sy = InStr(1, Mystate, "S")
If Sy <> "0" Then
tim.Enabled = True
End If
end sub
Private Sub tim_Timer()
tim.Interval = 5000
Sy1 = Mid(Mystate, Sy + 1, 1)
Sy2 = Mid(Mystate, Sy + 2, 1)
End Sub