打开串口
MSComml.CommPort =2
'设定Com2
If MSComml.PortOpen = False Then
MSComm1.Settings = "9600,n,8,1"
'9600波特率,无校验,8位数据位,1位停止位
MSComm1.PortOpen = True
'打开串口
End if
MSComm1.OutBufferCount = 0
'清空发送缓冲区
MSComm1.InBufferCount = 0
'滑空接收缓冲区
'发送字符数组数据时注意ByteArray必须事先定义赋值
Dim ByteArray as byte( )
'定义动态数组
ReDim ByteArray(1)
'重定义数组大小
ByteArray ( 0 ) =&H1B
ByteArray ( 1 ) =&H65
MSComm1.Output = ByteArray
End Sub