我有一个串行设备,它以38400的波特率向我发送数据,我就像这样?@D00014C000 000
。我可以在ritchtextbox上看到数据,但我想要做的是在列表框中使用字符串中的一些字符。
例如,我想在listbox3中出现字符“14C”。我尝试了子串和mid函数,但listbox lidnt正常工作并丢失字符或混淆它们。这是我的代码。有什么建议吗?
Imports System
Imports System.ComponentModel
Imports System.Threading
Imports System.IO.Ports
Public Class frmMain
Dim myPort As Array
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
If Me.rtbReceived.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.rtbReceived.Text &= [text]
Dim fine As String = Mid([text], 7, 3)
Dim list As Integer = ListBox3.Items.Add(fine)
End If
End Sub
结束班