Option ExplicitPrivate Sub Command1_Click() '发送 Dim arr(4) As Byte arr(0) = 78 arr(1) = 78 arr(2) = 78 arr(3) = 78 arr(4) = 78 MSComm1.Output = arr End SubPrivate Sub Command2_Click() '接收 Dim js() As Byte Dim l As Integer Dim i As Integer js = MSComm1.Input l = UBound(js) For i = 0 To l Text1(i) = Hex(js(i)) Next End SubPrivate Sub Form_Load() MSComm1.CommPort = 1 MSComm1.Settings = "9600,n,8,1" MSComm1.InputMode = comInputModeBinary MSComm1.PortOpen = True End Sub
Dim arr(4) As Byte
arr(0) = 78
arr(1) = 78
arr(2) = 78
arr(3) = 78
arr(4) = 78
MSComm1.Output = arr
End SubPrivate Sub Command2_Click() '接收
Dim js() As Byte
Dim l As Integer
Dim i As Integer
js = MSComm1.Input
l = UBound(js)
For i = 0 To l
Text1(i) = Hex(js(i))
Next
End SubPrivate Sub Form_Load()
MSComm1.CommPort = 1
MSComm1.Settings = "9600,n,8,1"
MSComm1.InputMode = comInputModeBinary
MSComm1.PortOpen = True
End Sub
你这样输出的是什么?
接受的时候Text1(i)是什么?