Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '(中略) SerialPort1.Open() '(中略) End Sub
Private portOpenTime As Date Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click '(中略) portOpenTime = Now SerialPort1.Open() '(中略) End Sub Private Sub SerialPort1_DataReceived(… Dim dtCurrent As Date = DateTime.Now 'データを受信した時刻 Dim span As TimeSpan = dtCurrent - portOpenTime 'Open してからの経過時間 Dim totalMilliseconds As Double = span.TotalMilliseconds '何ミリ秒経過したのか '(中略) End Sub