Visual Basic: MSComm Control

Output Property Example

The following example shows how to send every character the user types to the serial port:

  Private Sub Form_KeyPress (KeyAscii As Integer)
   Dim Buffer as Variant
   
   ' Set and open port
   MSComm1.CommPort = 1
   MSComm1.PortOpen = True

   Buffer = Chr$(KeyAscii)
   MSComm1.Output = Buffer
End Sub