vb6 串口通讯 我读取的数据只在开始时读取,读取一次后就不再读取了,怎么办??求代码
PrivateSubMSComm1_OnComm()Dimcmdin()AsByte'接收数据字节变量DimIndexAsIntegerIfMSComm1.CommEve...
Private Sub MSComm1_OnComm()
Dim cmdin() As Byte '接收数据字节变量
Dim Index As Integer
If MSComm1.CommEvent = comEvReceive Then
If MSComm1.InBufferCount = 10 Then
cmdin = MSComm1.Input
If i = 0 Then
Label1(0).Caption = TwoBytes(cmdin(0), cmdin(1))
Label1(1).Caption = TwoBytes(cmdin(2), cmdin(3))
ElseIf i = 1 Then
Label1(2).Caption = TwoBytes(cmdin(0), cmdin(1))
ElseIf i = 2 Then
Label1(3).Caption = TwoBytes(cmdin(0), cmdin(1))
ElseIf i = 5 Then
Label1(4).Caption = TwoBytes(cmdin(0), cmdin(1))
Text1(0).Text = TwoBytes(cmdin(2), cmdin(3))
ElseIf i = 4 Then
Label1(5).Caption = TwoBytes(cmdin(0), cmdin(1))
Text1(1).Text = TwoBytes(cmdin(2), cmdin(3))
End If
End If
End If
T = True
End Sub 展开
Dim cmdin() As Byte '接收数据字节变量
Dim Index As Integer
If MSComm1.CommEvent = comEvReceive Then
If MSComm1.InBufferCount = 10 Then
cmdin = MSComm1.Input
If i = 0 Then
Label1(0).Caption = TwoBytes(cmdin(0), cmdin(1))
Label1(1).Caption = TwoBytes(cmdin(2), cmdin(3))
ElseIf i = 1 Then
Label1(2).Caption = TwoBytes(cmdin(0), cmdin(1))
ElseIf i = 2 Then
Label1(3).Caption = TwoBytes(cmdin(0), cmdin(1))
ElseIf i = 5 Then
Label1(4).Caption = TwoBytes(cmdin(0), cmdin(1))
Text1(0).Text = TwoBytes(cmdin(2), cmdin(3))
ElseIf i = 4 Then
Label1(5).Caption = TwoBytes(cmdin(0), cmdin(1))
Text1(1).Text = TwoBytes(cmdin(2), cmdin(3))
End If
End If
End If
T = True
End Sub 展开
1个回答
2013-09-17
展开全部
或许后面的数据没有触发接收事件
追问
应该触发了 有一块还没调出来的表的数值读出来了,但好的那块没读出来……而且位置不对,明明我都规定了的啊……
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询