-1

I am developing software that uses serial communications for data transmission . My problem is related to richtextbox which is I want to make a popup InputBox when the word "change configuration ?" appears in the richtextbox .

Please help me.

this is my configuration :

    Private Sub btnWrEr_Click(sender As Object, e As EventArgs) Handles btnWrEr.Click
    SerialPort1.WriteLine("write erase" & vbCr & vbCr & "reload" & vbCr)
    If InStr(rtbReceived.Text, "System configuration has been modified. Save? [yes/no]:") Then
        Dim save As String
        save = InputBox("System configuration has been modified. Save? [yes/no]:", "yes/no")
        SerialPort1.WriteLine(save & vbCr)
    Else
        SerialPort1.Write(vbCr)
    End If
End Sub

and this is my rtb recieved coding :

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]
    End If

End Sub

Private Sub rtbReceived_TextChanged(sender As Object, e As EventArgs) Handles rtbReceived.TextChanged
    rtbReceived.SelectionStart = rtbReceived.TextLength
    rtbReceived.ScrollToCaret()
End Sub

1 Answers1

0

This looks pretty straightforward just add this code to your text changed event

    If RichTextBox1.Text.Contains("change configuration ?") Then
        InputString = InputBox("How do you want to change it?")
    End If

or instead of the line in the if..end if statement just call another sub

David Wilson
  • 4,369
  • 3
  • 18
  • 31