Sample Code (Comm)

Example code is from a project with a Comm control on the main form named MSComm1.

Private Sub Form_Load()
Rem set properties for com port 1 at 2400 bps,
Rem no parity, 8 data bits, and 1 stop bit.
MSComm1.Settings = "2400,n,8,1"
MSComm1.CommPort = 1
    
Rem open the com port
MSComm1.PortOpen = True
    
Rem Write to the com port
MSComm1.Output = "Hello, Com port!!!"
   
Rem close the com port
MSComm1.PortOpen = False
End Sub
            

This OnComm event handler example detects an error, or tells the user when the string has been written to the Comm port.