'发送字符数组数据时注意ByteArray必须事先定义赋值 Dim ByteArray as byte( )
'定义动态数组 ReDim ByteArray(1)
'重定义数组大小 ByteArray ( 0 ) =0 ByteArray ( 1 ) = 1 MSComm1.Output = ByteArray End Sub
private Sub MScommEvent( ) Select Case MSComm1.CommEvent Case comEvReceive Dim Buffer As Variant MSComm1.InputLen = 0 '接收二进制数据 MSComm1.InputMode= ComInputModeBinary Buffer=MSComm1.Input '接收字符数据 MSComm1.InputMode=comInputModeText Buffer = MSComml.Input Case else End Select End sub ( 程序1)