我收到来自串口的消息,每条消息都是从微控制器发送的,有不同的延迟,其中两个发送延迟10毫秒,一个50毫秒,另一个100毫秒。我正在尝试计算每条消息的延迟并将其显示在listview1上。我到目前为止尝试了创建timer2,其间隔= 1,并且每当计时器过去时它将VAR增加1
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles
Timer2.Tick
timer_count = timer_count + 1
End Sub
然后,当我们收到来自连续剧的消息时,我们把" timer_count"进入 listview
Dim lvi As New ListViewItem(can_id)
lvi.SubItems.Add(dlc)
lvi.SubItems.Add(data)
lvi.SubItems.Add(timer_count)
lvi.SubItems.Add(count)
lvi.SubItems.Add(asciival)
ListView1.Items.Add(lvi)
然后当我们更新listview的子项时,我们从当前的timer_count中减去之前的timer_count值。
Dim founditem As ListViewItem = ListView1.FindItemWithText(articlecheck)
If Not (founditem Is Nothing) Then
founditem.SubItems(0).Text = can_id
founditem.SubItems(3).Text = timer_count - founditem.SubItems(3).Text
问题在于它不起作用, subitem(3)中的值总是在增加。任何提示或想法?再次感谢