I have a replace button which has to replace a word that is searched inside the richtextbox(rtb).But the code is not working, help me identify my mistake. Thank you
If HTMLopt.rtb.SelectedText.Length <> 0 Then
HTMLopt.rtb.SelectedText = txtReplacementText.Text
End If
Dim StartPosition As Integer = HTMLopt.rtb.SelectionStart + 2
Dim SearchType As CompareMethod
If chkMatchCase.Checked = True Then
SearchType = CompareMethod.Binary
Else
SearchType = CompareMethod.Text
End If
StartPosition = InStr(StartPosition, HTMLopt.rtb.Text, txtSearchTerm.Text, SearchType)
If StartPosition = 0 Then
MessageBox.Show("String: '" & txtSearchTerm.Text.ToString() & "' not found", "No Matches", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
Exit Sub
End If
HTMLopt.rtb.Select(StartPosition - 1, txtSearchTerm.Text.Length)
HTMLopt.rtb.ScrollToCaret()
HTMLopt.rtb.Focus()