谁能给段代码?
我从一个仪器取数据,想实现每五个数取一次移动平均.

解决方案 »

  1.   

       SetRThreshold(5);   大于等于1个字符则触发OnComm  
       SetInPutLen(5); 每次从输入缓冲读五个
       
       用一个变量保存 接受到的数据   if( 接受完毕之后)
          SetInBufferCount(0);  清空接受缓冲区   这三个函数综合使用就可以了
      

  2.   

    vb代码,自己参考一下!!
    Private Function AVG() As Double
        Dim i As Long, v As Double
        For i = 0 To 4
            v = v + m_aData(i)
        Next
        AVG = v / 5
    End FunctionPrivate Sub Form_Load()
        Timer1.Interval = 1000
    End SubPrivate Sub Timer1_Timer()
        m_aData(m_iNextInut) = f()
        m_iNextInut = (m_iNextInut + 1) Mod 5
        If m_iNextInut = 0 Then Label1 = AVG()
    End Sub