好的!我想制作一个应用程序以在进度条上显示接收到的数据微控制器发送从 0 到 1023 的 adc 值,但我不知道如何制作这个我制作的串口终端:
公开课形式1 将 RSPort 调暗为数组 委托子 SetTextCallback(ByVal [text] As String) Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) 处理 MyBase.Load RSPort = IO.Ports.SerialPort.GetPortNames() LBaud.SelectedIndex = 1 对于 i = 0 到 UBound(RSPort) LPort.Items.Add(RSPort(i)) 下一个 LPort.Text = LPort.Items.Item(0) bDisconnect.Enabled = False 结束子 Private Sub bConnect_Click(ByVal sender As Object, ByVal e As EventArgs) 处理 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 结束子 Private Sub bDisconnect_Click(ByVal sender As Object, ByVal e As EventArgs) 处理 bDisconnect.Click SerialPort1.Close() bConnect.Enabled = True bDisconnect.Enabled = False 结束子 Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) 处理 SerialPort1.DataReceived ReceivedText(SerialPort1.ReadExisting()) 结束子 Private Sub ReceivedText(ByVal [text] As String) If rtbReceived.InvokeRequired Then Dim x As New SetTextCallback(AddressOf ReceivedText) 调用(x,新对象(){(文本)}) 别的 rtbReceived.Text &= [文本] 万一 结束子 Private Sub LBaud_SelectedIndexChanged(sender As Object, e As EventArgs) 处理 LBaud.SelectedIndexChanged 如果 SerialPort1.IsOpen = False 那么 SerialPort1.BaudRate = LBaud.Text 别的 MsgBox("仅当端口关闭", vbCritical) 万一 结束子 Private Sub LPort_SelectedIndexChanged(sender As Object, e As EventArgs) 处理 LPort.SelectedIndexChanged 如果 SerialPort1.IsOpen = False 那么 SerialPort1.PortName = LPort.Text 别的 MsgBox("仅当端口关闭", vbCritical) 万一 结束子 结束类
查看数据女巫看起来相同这个“1023101509410888085208510828075706520558048704290374”,我想在进度栏中显示这个,但每个数字都是一一收到的......对不起我的英语,我是罗马尼亚人......