有关于MSComm控件详解

本文详细介绍了MSComm控件的重要属性,如CommPort、Settings和PortOpen,以及如何处理通信错误和事件。通过CommEvent属性可以获取错误或事件的数值代码,例如comEventBreak、comEvReceive等。此外,还讨论了EOFEnable、InBufferCount、InBufferSize、InputLen、InputMode等属性,用于控制输入缓冲区的行为。同时,Output、RThreshold和SThreshold则涉及输出和传输事件的管理。
摘要由CSDN通过智能技术生成
  Visual Basic: MSComm Control
 
      The MSComm control provides serial communications for your application by allowing the transmission and reception of data through a serial port.
 
1.Error Messages (MS Comm Control)

The following table lists the trappable errors for the MSComm control.

 

Constant Value Description
comInvalidPropertyValue 380 Invalid property value
comSetNotSupported 383 Property is read-only
comGetNotSupported 394 Property is read-only
comPortOpen 8000 Operation not valid while the port is opened
8001 Timeout value must be greater than zero
comPortInvalid 8002 Invalid Port Number
8003 Property available only at run time
8004 Property is read only at runtime
comPortAlreadyOpen 8005 Port already open
8006 The device identifier is invalid or unsupported
8007 The device's baud rate is unsupported
8008 The specified byte size is invalid
8009 The default parameters are in error
8010 The hardware is not available (locked by another device)
8011 The function cannot allocate the queues
comNoOpen 8012 The device is not open
8013 The device is already open
8014 Could not enable comm notification
comSetCommStateFailed 8015 Could not set comm state
8016 Could not set comm event mask
comPortNotOpen 8018 Operation valid only when the port is open
8019 Device busy
comReadError 8020 Error reading comm device
comDCBError 8021 Internal error retrieving device control block for the port
 
2.Properties Description

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

 

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.

 


CommEvent

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

Syntax

object.CommEvent

The CommEvent property syntax has these parts:

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


Remarks

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               

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值