不好意思,最好改成
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
MSComm1.InputLen = 0
MSComm1.Output = "AT" + Chr$(13) + Chr$(10)
Do
DoEvents
if mscomm1.inputlen>0 then temp$ = temp$ & MSComm1.Input
Loop Until InStr(temp$, "OK")
setConnection = True
RaiseEvent addQueueStatus("连接成功!")
End If