Home > Software engineering >  Pray god help me to see where this code is wrong, an error is a type mismatch
Pray god help me to see where this code is wrong, an error is a type mismatch

Time:09-28

Dim rx (7) As Byte

Private Sub Command1_Click ()
MSComm1. The Settings="2400, N, 8, 1" 'set the baud rate of 4800, no parity bit, 8 data bits, one stop bit
MSComm1.Com mPort=4 'set serial port
MSComm1. InBufferSize=64 'set the receive buffer size
MSComm1. OutBufferSize=64 'set the send buffer size
MSComm1. RThreshold=1 'set and returns the number of characters produced oncomm events
MSComm1. SThreshold=0
MSComm1. InputLen=0 'read the entire buffer
MSComm1. An InputMode=comInputModeBinary 'in text mode receiving
MSComm1. InBufferCount=0 'empty receive buffer
MSComm1. OutBufferCount=0 'empty send buffer
If MSComm1. PortOpen=False Then
MSComm1. PortOpen=True
End the If

Private Sub MSComm1_OnComm ()
Dim the count As Integer
Dim real As Long
Real=0
Rx (7)=MSComm1. Input
For the count=0 To 7
Real=real * 2 + rx (count)
Next the count

CodePudding user response:

 rx (7)=MSComm1. Input 

The binary Input the returned byte array is under way,
 Dim data () As Byte 
Data=https://bbs.csdn.net/topics/MSComm1.Input
Rx (7)=data (0)

CodePudding user response:

When reading data, with array name directly, and then use subscript turn taking,
  • Related