Go to Project, References…
Check off OLE Automation.
Then go to Project, Components…
Check off Microsoft Comm Control 6.0.
Open your toolbox and drop the MSComm control on your form.
Put the following in a module or a form:
Public
Sub SendSerialPortByte(comm As MSComm, b As Integer)
comm.Output = Chr$(b)
End
Sub
Public
Sub InitSerialPort(comm As MSComm)
'
'Setup Com port
'
' Fire Rx Event Every Byte
comm.RThreshold = 1
' 9600 Baud, No Parity, 8 Data Bits, 1
Stop Bit
comm.Settings = "9600,N,8,1"
' Open COM1
comm.CommPort = 1
comm.PortOpen = True
End
Sub
Basically all you need to do in order to use these functions is pass in the name of the MSComm control. In the case of sending a byte to the port, as you can see we just set the .Output field of the control.
The serial port may be old and outdated, but it is fairly easy to program for.