Select Case Err.Number
Case comPortAlreadyOpen
MsgBox "串口冲突,请更改串口号"
Case Else
MsgBox "没有发现此串口,请确认连接"
End Select
on error goto exit1
if mscomm1.portopen then mscomm1.portopen=false
exit sub
exit1:
msgbox "串口已经被别得程序打开,请正确设定通讯参数! "
end