Dim myStopwatch As New System.Diagnostics.Stopwatch()

  Private Sub SerialPort1_PinChanged(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialPinChangedEventArgs) Handles SerialPort1.PinChanged
        If Timer1.Enabled = False Then  'もしタイマがスタートしてなかったら(初回)
            myStopwatch.Start()
            Timer1.Enabled = True
            Label1.BackColor = Color.Red

        Else
            'ストップウォッチを配列に追加
            'Dim elaspedTime As Double = CDbl(myStopwatch.Elapsed.TotalMilliseconds) * 1000 / 20.83
            '配列の大きさを1足して
            'Array.Resize(timeArray, timeArray.Length + 1)
            '配列の最後に追加
            'timeArray(timeArray.Length - 1) = elaspedTime
            Debug.Print(myStopwatch.Elapsed.TotalMilliseconds)
            'ストップウォッチをリセット
            'myStopwatch.Reset()
            'タイマのインターバルを再設定
            'Timer1.Interval = 1000

        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox(Stopwatch.IsHighResolution, , "Stopwatch.IsHighResolution")
        MsgBox(Stopwatch.Frequency, , "Stopwatch.Frequency")
    End Sub

    'timeoutしたら。
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        MsgBox("tick")
        Timer1.Enabled = False
        myStopwatch.Stop()
        myStopwatch.Reset()
        Label1.BackColor = Color.White

        'waveファイルを作成して
        MakeWaveFile()

        'ファイルを保存して
        SaveWaveFile()
        '配列のリセット

    End Sub