Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
' MSComm1.RThreshold = 0
If MSComm1.InBufferCount Then
infolen = MSComm1.InBufferCount
ch1 = MSComm1.Input
Select Case Flag
Case 1
combuf = combuf + ch1
Select Case Flag
Case 1
If InStr(1, combuf, "CONNECT") > 0 Then‘执行到这一句就不行应该是受到connect,但受到的是connec t,中间加了一个空格,所以无法执行,而用超级终端发就没有问题,不知道什么原因??
Select Case MSComm1.CommEvent
Case comEvReceive
' MSComm1.RThreshold = 0
If MSComm1.InBufferCount Then
infolen = MSComm1.InBufferCount
ch1 = MSComm1.Input
Select Case Flag
Case 1
combuf = combuf + ch1
Select Case Flag
Case 1
If InStr(1, combuf, "CONNECT") > 0 Then‘执行到这一句就不行应该是受到connect,但受到的是connec t,中间加了一个空格,所以无法执行,而用超级终端发就没有问题,不知道什么原因??
还有接收时。你可以用文本方式接收。
If MSComm1.CommEvent <> comEvReceive Then Exit Sub '仅处理received
MSComm1.InputMode = comInputModeText
inputstring = MSComm1.Input
inputstring = Mid(inputstring, 3, 7)
MSComm1.InBufferCount = 0
If inputstring = "CONNECT" Then
……
end if
这段程序调试已通过,你可以试试