Public Class Form2 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If RadioButton1.Checked Then Form1.SerialPort1.BaudRate = 4800 End If If RadioButton2.Checked Then Form1.SerialPort1.BaudRate = 9600 End If If RadioButton3.Checked Then Form1.SerialPort1.BaudRate = 19200 End If Me.Visible = False End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Not Form1.SerialPort1.IsOpen Then Dim port As String port = ListBox1.SelectedItem If Not port = Nothing Then Form1.SerialPort1.PortName = port Dim Title As String = "Port" Try ' Set up structured error handling. CheckForIllegalCrossThreadCalls = False Form1.SerialPort1.Open() 'Form1.Timer1.Enabled = True Catch ex As Exception When Not Form1.SerialPort1.IsOpen MsgBox("Com Port already in use by another application", MsgBoxStyle.Critical, "Error") Finally 'Beep() ' This line is executed no matter what. End Try Else MsgBox("Select a port", MsgBoxStyle.DefaultButton1, "Error") End If End If End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim instance As IO.Ports.SerialPort = Form1.SerialPort1 For Each portName As String In My.Computer.Ports.SerialPortNames ListBox1.Items.Add(portName) Next RadioButton2.Checked = True End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Form1.SerialPort1.IsOpen Then Form1.SerialPort1.Close() End If End Sub End Class