OK!我想制作一个应用程序来显示进度条上的接收数据,微控制器将adc值从0发送到1023,但我不知道如何制作这个i maked串口终端:
Public Class Form1 Dim RSPort As Array Delegate Sub SetTextCallback(ByVal [text] As String) Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load RSPort = IO.Ports.SerialPort.GetPortNames() LBaud.SelectedIndex = 1 For i = 0 To UBound(RSPort) LPort.Items.Add(RSPort(i)) Next LPort.Text = LPort.Items.Item(0) bDisconnect.Enabled = False End Sub Private Sub bConnect_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bConnect.Click SerialPort1.PortName = LPort.Text SerialPort1.BaudRate = LBaud.Text SerialPort1.Parity = IO.Ports.Parity.None SerialPort1.StopBits = IO.Ports.StopBits.One SerialPort1.DataBits = 8 SerialPort1.Open() bConnect.Enabled = False bDisconnect.Enabled = True End Sub Private Sub bDisconnect_Click(ByVal sender As Object, ByVal e As EventArgs) Handles bDisconnect.Click SerialPort1.Close() bConnect.Enabled = True bDisconnect.Enabled = False End Sub 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 rtbReceived.InvokeRequired Then Dim x As New SetTextCallback(AddressOf ReceivedText) Invoke(x, New Object() {(text)}) Else rtbReceived.Text &= [text] End If End Sub Private Sub LBaud_SelectedIndexChanged(sender As Object, e As EventArgs) Handles LBaud.SelectedIndexChanged If SerialPort1.IsOpen = False Then SerialPort1.BaudRate = LBaud.Text Else MsgBox("Only if port is Closed", vbCritical) End If End Sub Private Sub LPort_SelectedIndexChanged(sender As Object, e As EventArgs) Handles LPort.SelectedIndexChanged If SerialPort1.IsOpen = False Then SerialPort1.PortName = LPort.Text Else MsgBox("Only if port is Closed", vbCritical) End If End Sub End Class
查看数据女巫看起来相同这个“1023101509410888085208510828075706520558048704290374”,我想在progess栏显示这个,但每个号码都是1比1收到...对不起我的英语我是罗马尼亚语...