1,502
社区成员
发帖
与我相关
我的任务
分享
Dim after As Double
Dim strTotal(11) as Byte
Dim s as Long
sckconnect1.SendData fx
'sckconnect1.Close
after = Now + 10# / 24# / 3600#
Do
DoEvents
If sckconnect1.State = 0 Then Exit Do
If Now > after Then
sckconnect1.Close
Exit Do
End If
Loop
Private Sub sckconnect1_DataArrival(ByVal bytesTotal As Long)
Dim strData() As Byte
Dim i As Long
Dim hexstr As String
On Error Resume Next
ReDim strData(bytesTotal-1)
sckconnect1.GetData strData
for i=0 to bytesTotal-1
if s+i<12 Then strTotal(s+i)=strData(i) else exit for
next
s=s+i
if s>=12 then
for i=0 to 11
hexstr=hexstr & Right("0"&Hex(strTotal(i)),2)
next
if hexstr="000100000006FF0F00640002" Then sckconnect1.Close
end if
End Sub