Visual Basic: MSComm Control

Visual Studio 6.0

CommEvent Property

See Also   Example   Applies To

Returns the most recent communication event or error. This property is not available at design time and is read-only at run time.



The CommEvent property syntax has these parts:

Part Description
object An object expression that evaluates to an object in the Applies To list.


Although the OnComm event is generated whenever a communication error or event occurs, the CommEvent property holds the numeric code for that error or event. To determine the actual error or event that caused the OnComm event, you must reference the CommEvent property.

The CommEvent property returns one of the following values for communication errors or events. These constants can also be found in the Object Library for this control.

Communication errors include the following settings:

Constant Value Description
comEventBreak 1001 A Break signal was received.
comEventFrame 1004 Framing Error. The hardware detected a framing error.
comEventOverrun 1006 Port Overrun. A character was not read from the hardware before the next character arrived and was lost.
comEventRxOver 1008 Receive Buffer Overflow. There is no room in the receive buffer.
comEventRxParity 1009 Parity Error. The hardware detected a parity error.
comEventTxFull 1010 Transmit Buffer Full. The transmit buffer was full while trying to queue a character.
comEventDCB 1011 Unexpected error retrieving Device Control Block (DCB) for the port.

Communications events include the following settings:

Constant Value Description
comEvSend 1 There are fewer than Sthreshold number of characters in the transmit buffer.
comEvReceive 2 Received Rthreshold number of characters. This event is generated continuously until you use the Input property to remove the data from the receive buffer.
comEvCTS 3 Change in Clear To Send line.
comEvDSR 4 Change in Data Set Ready line. This event is only fired when DSR changes from 1 to 0.
comEvCD 5 Change in Carrier Detect line.
comEvRing 6 Ring detected. Some UARTs (universal asynchronous receiver-transmitters) may not support this event.
comEvEOF 7 End Of File (ASCII character 26) character received.

Data Type