Click here to Skip to main content
16,015,973 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
moi je peux modifier les donnes récues au lieu d'afficher en série je veux lorsque trouver "04" fait un retour a la ligne et "04" affiche au front de la ligne et toujours la meme opération
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


What I have tried:

salut a tout moi je fait un serail communication et le code est fonctionne bien
mais j'ai un un probleme lorsque les donnes récués sont affiche ds la meme ligne.

moi je veux arranger les donnes récues lorsque il ya un caractére se "04" le text fait retour a la ligne avec que "04" reste au front de la ligne
Voila la code serial communication mais le texte c'est pas de forme qui je le desire
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
Posted
Updated 25-Apr-22 6:54am
v2
Comments
CHill60 25-Apr-22 7:26am    
You have already been told this is an English language site. Use English only please.

On vous a déjà dit qu'il s'agissait d'un site en anglais. Utilisez uniquement l'anglais s'il vous plaît

1 solution

If you use Replace for dataIN (which seems to be your input):

VB
dataIN=Replace(dataIN,"04", Environment.NewLine & "04")

you should get

04 {bla bla bla}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900