Google Translate:I can modify the data received instead of displaying in series I want when finding "04" makes a line break and "04" displays at the front of the line and always the same operation
Goggle Translate:hello to all me I made a serail communication and the code is working well but I have a problem when the received deals are displayed in the same line. I want to arrange the deals received when there is a character "04" the text wraps with "04" remaining at the front of the line Here is the serial communication code but the text is not in the form that I want
Imports System.IO.Ports Public Class Form1 Dim dataIN As String Dim datainterruption As String Dim dataOUT As String Private Delegate Sub AccesDelegue(ByVal AjouterText As String) Private Sub AccesFormPrinpal(ByVal TextForms As String) dataOUT = TextForms TxtDonnesRecus.Text = dataOUT End Sub Private Sub PortAcceesInteruption(ByVal bufferin As String) Dim textinteruption As Object = {bufferin} Dim delegateinteruption As AccesDelegue delegateinteruption = New AccesDelegue(AddressOf AccesFormPrinpal) MyBase.Invoke(delegateinteruption, bufferin) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load dataIN = "" dataOUT = "" BtnConnecter.Enabled = False BtnEnvoyesData.Enabled = False End Sub Private Sub BtnChercherPorts_Click(sender As Object, e As EventArgs) Handles BtnChercherPorts.Click CboxPorts.Items.Clear() For Each PortDinsponible As String In My.Computer.Ports.SerialPortNames CboxPorts.Items.Add(PortDinsponible) Next If CboxPorts.Items.Count > 0 Then CboxPorts.Text = CboxPorts.Items(0) MessageBox.Show("selectionner le port de travail") BtnConnecter.Enabled = True Else MessageBox.Show("NON Port Trouve") BtnConnecter.Enabled = False BtnEnvoyesData.Enabled = False CboxPorts.Items.Clear() End If End Sub Private Sub BtnConnecter_Click(sender As Object, e As EventArgs) Handles BtnConnecter.Click If BtnConnecter.Text = "Connecter" Then Try With SerialPort1 .BaudRate = 9600 .Parity = IO.Ports.Parity.None .StopBits = IO.Ports.StopBits.One .DataBits = 8 .PortName = CboxPorts.Text .Open() End With BtnConnecter.Text = "deconnecter" BtnEnvoyesData.Enabled = True Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try ElseIf BtnConnecter.Text = "deconnecter" Then BtnConnecter.Text = "Connecter" BtnEnvoyesData.Enabled = False TxtDonnesRecus.Clear() SerialPort1.Close() End If End Sub Private Sub BtnEnvoyesData_Click(sender As Object, e As EventArgs) Handles BtnEnvoyesData.Click SerialPort1.DiscardOutBuffer() dataIN = TxtEnvoyerDonnes.Text SerialPort1.Write(dataIN) End Sub Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Dim datainterruption As String datainterruption = SerialPort1.ReadExisting PortAcceesInteruption(datainterruption) End Sub End Class
Replace
dataIN
dataIN=Replace(dataIN,"04", Environment.NewLine & "04")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)