Private Sub Reset() If SerialPort1.IsOpen Then SerialPort1.DtrEnable = True Thread.Sleep(2) SerialPort1.DtrEnable = False SerialPort1.BreakState = True Thread.Sleep(50) SerialPort1.BreakState = False Thread.Sleep(5) SerialPort1.DiscardInBuffer() End If End Sub 'Note: the line Imports System.Threading must be included in the code