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