Export (0) Print
Expand All
81 out of 146 rated this helpful - Rate this topic

Visual Basic: MSComm Control

Visual Studio 6.0

MSComm Control

See Also   Example   Properties   Methods   Events

The MSComm control provides serial communications for your application by allowing the transmission and reception of data through a serial port.

Syntax

MSComm

Remarks

The MSComm control provides the following two ways for handling communications:

  • Event-driven communications is 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 MSComm control's OnComm event to trap and handle these communications events. The OnComm event also detects and handles communications errors. For a list of all possible events and communications errors, see the CommEvent property.

  • 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 MSComm 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 MSComm control. The port address and interrupt address can be changed from the Windows Control Panel.

Although the MSComm control has many important properties, there are a few that you should be familiar with first.

Properties Description
CommPort Sets and returns the communications port number.
Settings Sets and returns the baud rate, parity, data bits, and stop bits as a string.
PortOpen Sets and returns the state of a communications port. Also opens and closes a port.
Input Returns and removes characters from the receive buffer.
Output Writes a string of characters to the transmit buffer.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.