VB codeOption Explicit
Dim sjByt() As Byte
Private Sub Command1_Click() '2进制发送
ReDim sjByt(1 To 8) '设置为8个元素
sjByt(1) = &H2
sjByt(2) = &H3
sjByt(3) = &H0
sjByt(4) = &H0
sjByt(5) = &H0
sjByt(6) = &H6
sjByt(7) = &HC5
sjByt(8) = &HFB
MSComm1.Output = sjByt '此命令执行一次发送8字节
End Sub
Private Sub Form_Load()
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeBinary '采用二进制传输
MSComm1.InBufferCount = 0 '清空接受缓冲区
MSComm1.OutBufferCount = 0 '清空传输缓冲区
MSComm1.RThreshold = 1 '产生MSComm事件
MSComm1.PortOpen = True
End Sub
接收由MSComm控件的OnComm完成
相关的代码见:
http://www.vbgood.com/viewthread.php?tid=83694&page=1#pid441972
3楼的回复.