首页上一页 1 下一页尾页 1 条记录 1/1页
请教:VB6.0的Winsock1_DataArrival函数中有一句总是报(实时错误'5',无效的过程调用和参数)
发表在VB答疑区
2016-05-03
是否精华
是
否
版块置顶:
是
否
老师您好,这是我在Winsock1_DataArrival(ByVal bytesTotal As Long)函数中写的三段数据串处理函数,三段函数的格式一样,但是第一段中的一句经常报错,总是报实时错误5(有时一运行就报错,有时运行一段时间报错,个人感觉函数好像正确,请大师指点问题出在哪里,怎么改)
'数据到达事件函数
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Dim n As Integer
Dim m As Integer
Dim j As Integer
Dim k As Integer
Winsock1.GetData s
'transmit_CANEthernet
If bytesTotal = 22 And Asc(Mid$(s, 2, 1)) = &H3 Then
Text7.Text = Asc(Mid$(s, 22, 1))[font color=#FF0000]'此语句总是报实时错误5[/font]
For m = 1 To 10
b(m) = Asc(Mid$(s, m + 2, 1))
Text3.Text = b(1) * 128 + b(2)
If m > 2 Then
Text6(m - 3).Text = b(m)
End If
Next
End If
'transmit_DIDOEthernet
If bytesTotal = 24 And Asc(Mid$(s, 2, 1)) = &H1 Then
Text53.Text = Asc(Mid$(s, 24, 1))
For j = 1 To 22
b(j) = Asc(Mid$(s, j + 2, 1))
Text1.Text = b(1) * 128 + b(2)
If j > 2 Then
Text4(j - 3).Text = b(j)
End If
Next
End If
'transmit_AIAOEthernet
If bytesTotal = 44 And Asc(Mid$(s, 2, 1)) = &H4 Then
Text52.Text = Asc(Mid$(s, 44, 1))
For n = 1 To 42
b(n) = Asc(Mid$(s, n + 2, 1))
Text2.Text = b(1) * 128 + b(2)
Next
For k = 0 To 19
Text5(k).Text = b(2 * k + 3) * 128 + b(2 * k + 4)
Next
End If
'数据到达事件函数
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Dim n As Integer
Dim m As Integer
Dim j As Integer
Dim k As Integer
Winsock1.GetData s
'transmit_CANEthernet
If bytesTotal = 22 And Asc(Mid$(s, 2, 1)) = &H3 Then
Text7.Text = Asc(Mid$(s, 22, 1))[font color=#FF0000]'此语句总是报实时错误5[/font]
For m = 1 To 10
b(m) = Asc(Mid$(s, m + 2, 1))
Text3.Text = b(1) * 128 + b(2)
If m > 2 Then
Text6(m - 3).Text = b(m)
End If
Next
End If
'transmit_DIDOEthernet
If bytesTotal = 24 And Asc(Mid$(s, 2, 1)) = &H1 Then
Text53.Text = Asc(Mid$(s, 24, 1))
For j = 1 To 22
b(j) = Asc(Mid$(s, j + 2, 1))
Text1.Text = b(1) * 128 + b(2)
If j > 2 Then
Text4(j - 3).Text = b(j)
End If
Next
End If
'transmit_AIAOEthernet
If bytesTotal = 44 And Asc(Mid$(s, 2, 1)) = &H4 Then
Text52.Text = Asc(Mid$(s, 44, 1))
For n = 1 To 42
b(n) = Asc(Mid$(s, n + 2, 1))
Text2.Text = b(1) * 128 + b(2)
Next
For k = 0 To 19
Text5(k).Text = b(2 * k + 3) * 128 + b(2 * k + 4)
Next
End If