PortOpen

This property sets and returns the state—either open or closed—of the communications port.

Syntax

object.PortOpen [= value]

Parameters

object
Object expression that evaluates to a Comm control.
value
Boolean expression that specifies the state of the communications port. Following are the settings for value:
True
Port is opened
False
Port is closed

Remarks

The PortOpen property is unavailable at design time.

Setting the PortOpen property to True opens the port. Setting it to False closes the port and clears the receive and transmit buffers. The Comm control automatically closes the serial port when your application is terminated.

Be sure the CommPort property is set to a valid port number before you open the port. If the CommPort property is set to an invalid port number when you try to open the port, the Comm control generates error 68 (device unavailable).

In addition, your serial port device must support the current values in the Settings property. If the Settings property contains communications settings that your device does not support, your device may not work correctly.

If either the DTREnable or the RTSEnable properties are set to True before you open the port, the properties are set to False when the port is closed. Otherwise, the DTR and RTS lines remain in their previous state.