If vars("g") = 1 Then
If vars("js") >= 3 And vars("js") <= 7 Then
Dim cnt As Integer = Ports(vars("com1")).BytesToRead
If cnt > 7 Then '缓冲区是否有数据
Dim V(cnt - 1) As Byte
Ports(vars("com1")).Read(V,0,cnt)
Dim str As String = V(0)
For x As Integer = 1 To cnt - 1
str = str & "-" & V(x)
Next
If str.Contains("0-0-0") Then
str = str.Replace("0-0-0","0")
Else
If str.Contains("-0-") Then
str = str.Replace("-0-","-")
End If
End If
Dim Values() As String
Dim s1,s2 As String
Values = str.split("-")
If Values.Length = 8 Then
s1 = DecToBin(Values(3)) & DecToBin(Values(2))
s2 = DecToBin(Values(5)) & DecToBin(Values(4))
s1 = BinToDec(s1)
s2 = BinToDec(s2)
e.form.Controls("TextBox" & vars("js") & "1").text = s1
e.form.Controls("TextBox" & vars("js") & "2").text = s2
End If
End If
End If
Dim i,i1 As Integer
If vars("js") = 7 Or vars("js") < 3 Then
i = 3
Else
i = vars("js") + 1
End If
i1 = i + 112
Dim Val() As Byte = New Byte() {1,112,i,i1,2}
vars("js") = i
Ports(vars("com1")).Write(Val, 0, Val.Length)
End If
这段代码在主窗口 TimerTick 请问哪里出问题了