i first locate the last word in my richtextbox then i check if that string matches a particular string .
then i replace the string with another string.
the problem is that whenever i enter the same string and click my "rename" button it renames both strings because if both strings are now "dog" then it will recognize lastWord as dog and not as the FINAL most recently entered word thus it will be renamed to something else .
private sub getwords()
dval = dval + 1
Dim lastWord As String = RichTextBox1.Text.Split(" ").Last
If dval = 1 And lastWord = "meu" Then
RichTextBox1.Text = RichTextBox1.Text.Replace(lastWord, "dog")
End If
MsgBox(lastWord)
If dval = 2 And RichTextBox1.Text.EndsWith("dog") And lastWord = "dog" Then
RichTextBox1.Text = RichTextBox1.Text.Replace(lastWord, "cat")
dval =0
End If
end sub