假设与FX2N通讯rivate Sub CommSet()
On Error GoTo err1
If CommFX.PortOpen = True Then
CommFX.PortOpen = False
End If
If Not CommFX.PortOpen Then
CommFX.CommPort = cboPort.ListIndex + 1 '通信口
CommFX.Settings = "9600,N,8,1" '固定值即可
CommFX.Handshaking = 0
CommFX.InputLen = 0
CommFX.OutBufferCount = 0
CommFX.InBufferCount = 0
CommFX.PortOpen = True
End If
Exit Sub
err1:
MsgBox Err.Description