接受处理的函数:
Function doData()
Dim recMsgByte() As Byte
Dim RecLen As Integer
Dim sTemp As String
Dim s1 As String
'Dim I As Integer
Dim countTim As Long
Dim flag As Boolean
flag = True
MDIForm1.MSComm1.RThreshold = 0 '关闭OnComm事件接
Do
DoEvents
i = i + 1
If i = 10000 Then
doData = "55 "
GoTo lab
End If
Loop Until MDIForm1.MSComm1.InBufferCount = recLenFlag
RecLen = MDIForm1.MSComm1.InBufferCount
ReDim recMsgByte(RecLen)
recMsgByte = MDIForm1.MSComm1.Input
sTemp = ""
For i = 0 To RecLen - 1
s1 = Hex(recMsgByte(i))
If Len(s1) < 2 Then s1 = "0" & s1
sTemp = sTemp & s1
Next i
doData = sTemp
lab:
MDIForm1.MSComm1.InBufferCount = 0 '清空输入寄存器
MDIForm1.MSComm1.OutBufferCount = 0 '清空传输缓冲区
End Function
详情回复
发表于 2007-11-15 13:28