Private Sub SendCommand(ByVal command As String) Dim response As String Try myComPort.WriteLine(command) response = myComPort.ReadLine Select Case response Case "0" lblStatus.Text = "LED 1 is OFF" Case "1" lblStatus.Text = "LED 1 is ON" Case Else End Select Catch ex As TimeoutException MessageBox.Show(ex.Message) Catch ex As InvalidOperationException MessageBox.Show(ex.Message) Catch ex As UnauthorizedAccessException MessageBox.Show(ex.Message) End Try End Sub Listing 4. The SendCommand routine sends a text command to the COM port and waits for a response.