Sets and returns the state of the communications port (open or closed). Not available at design time.
object.PortOpen [ = value ]
The parts of the PortOpen property syntax are described in the following table.
Part | Description |
---|---|
object | An object expression that evaluates to an object. |
value | A Boolean expression that specifies the state of the communications port. |
The settings for value are described in the following table.
Setting | Description |
---|---|
True | Port is opened. |
False | Port is closed. |
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.
Make sure the CommPort property is set to a valid port number before opening 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 hardware does not support, your hardware may not work correctly.
If either the DTREnable or the RTSEnable properties are set to True before the port is opened, the properties are set to False when the port is closed. Otherwise, the DTR and RTS lines remain in their previous state.
Boolean