Try 'ポート名のセット SerialPort1.PortName = TextBox1.Text Call SerialPort1.Open() SerialPort1.DtrEnable = True SerialPort1.RtsEnable = True Catch ex As Exception MessageBox.Show(ex.Message, "Error") End Try
Dim mes As String mes = Chr(5) & "01" & Chr(2) & "RPV01" & Chr(3) & "C5" Debug.Print("データ送信=SerialPort1.WriteLine(" & mes & ")")
SerialPort1.WriteLine(mes)
Try Debug.Print("受信開始") Dim Read As String Debug.Print("SerialPort1.ReadLine") Read = SerialPort1.ReadLine MessageBox.Show("Read=" & Read) Catch ex As Exception MsgBox("受信エラー") End Try