InputMode Property Example

This example reads 10 bytes of binary data from the communications port and assigns it to a byte array.

Private Sub Command1_Click()
Dim Buffer as Variant
Dim Arr() as Byte

' Set and open port
MSComm1.CommPort = 1
MSComm1.PortOpen = True

' Set InputMode to read binary data
MSComm1.InputMode = comInputModeBinary

' Wait until 10 bytes are in the input buffer
Do Until MSComm1.InBufferCount < 10
  DoEvents
Loop

' Store binary data in buffer
Buffer = MSComm1.Input

' Assign to byte array for processing
Arr = Buffer

End Sub