MSComm1.PortOpen = True 在运行时,总是出现8002错误 ,这到底是怎么回事
PrivateSubCommand9_Click()IfCommand9.Caption="打开串口"ThenCommand9.Caption="关闭串口"MSComm1...
Private Sub Command9_Click()
If Command9.Caption = "打开串口" Then
Command9.Caption = "关闭串口"
MSComm1.PortOpen = True
Else: Command9.Caption = "打开串口"
MSComm1.PortOpen = False
End If
End Sub
一点击打开串口就直接弹出8002错误 展开
If Command9.Caption = "打开串口" Then
Command9.Caption = "关闭串口"
MSComm1.PortOpen = True
Else: Command9.Caption = "打开串口"
MSComm1.PortOpen = False
End If
End Sub
一点击打开串口就直接弹出8002错误 展开
展开全部
你在打开串口之前必须先设置串口的参数,端口号,波特率等属性,例如:
Private Sub Command9_Click()
If Command9.Caption = "打开串口" Then
Command9.Caption = "关闭串口"
MSComm1.PortOpen = True
Else
Command9.Caption = "打开串口"
MSComm1.PortOpen = False
End If
End Sub
Private Sub Form_Load()
MSComm1.Settings = "9600,n,8,1"
MSComm1.CommPort = 1 'COM1
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询