private void button2_Click(object sender, EventArgs e) { string COM; COM = comboBox1.Text; if (COM.Equals("")) { MessageBox.Show("포트번호를 입력해주세요"); } else { serialPort = new SerialPort("COM" + COM, 9600, Parity.None, 8, StopBits.One); try { serialPort.Open(); }catch (IOException) { MessageBox.Show("Not Connect!"); return; } MessageBox.Show("Successfully Connect!"); serialPort.Close(); } }