The Comm control provides serial communications for your application by allowing the transmission and reception of data through a serial port.
Comm
The Comm properties, methods, and events listed in the following table are supported:
Properties | Methods | Events |
---|---|---|
Break | None | OnComm |
CDHolding | ||
CommEvent | ||
CommID | ||
CommPort | ||
CTSHolding | ||
DSRHolding | ||
DTREnable | ||
Handshaking | ||
InBufferCount | ||
Index | ||
Input | ||
InputLen | ||
InputMode | ||
Name | ||
NullDiscard | ||
OutBufferCount | ||
Output | ||
Parent | ||
ParityReplace | ||
PortOpen | ||
Rthreshold | ||
RTSEnable | ||
Settings | ||
SThreshold |
The Comm ActiveX control can handle communications in two ways: by notifying you when a communication event or error has occurred and by polling for events and errors.
Event-driven communications are a very powerful method for handling serial port interactions. In many situations, you want to be notified the moment an event takes place, such as when a character arrives or a change occurs in the Carrier Detect (CD) or Request To Send (RTS) lines. In such cases, use the Comm control's OnComm event to trap and handle these communications events. The OnComm event also detects and handles communications errors.
You can also poll for events and errors by checking the value of the CommEvent property after each critical function of your program. This may be preferable if your application is small and self-contained. For example, if you are writing a simple phone dialer, it may not make sense to generate an event after receiving every character, because the only characters you plan to receive are the OK response from the modem.
Each Comm control you use corresponds to one serial port. If you need to access more than one serial port in your application, you must use more than one Comm control. The port address and interrupt address can be changed from the Windows Control Panel.