본문 바로가기
호구지책/VB6

[VB6] 공용컨트롤 개요

by 하늘의흐름 2017. 12. 13.
반응형

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.

PropertiesDescription
CommPortSets and returns the communications port number.
SettingsSets and returns the baud rate, parity, data bits, and stop bits as a string.
PortOpenSets and returns the state of a communications port. Also opens and closes a port.
InputReturns and removes characters from the receive buffer.
OutputWrites a string of characters to the transmit buffer.


반응형

댓글