I'm using the replace function During the 'Change' Event of a RichTextBox. I'm wanting it to look for certain keywords in the body of the text and then Capitalize them or Change the Color(on the fly). I've had success if I do it from a command button, but if I do it (on the fly) I get bizarre results.
What I have so far:
Private Sub RTB_Change()
RTB.Text = Replace(RTB.Text, "bob", "BOB"
End Sub
The text is returned to the box in reverse order. I tried the 'StrReverse' function, but that's when it got really strange.
I think what is happening is that when the new string is inserted into RTB.Text, that the cursor position remains in front of the text, rather than in the back, so it may be as simple as telling the cursor to go to the end of the text. However, I lack the knowhow to make that happen. Any help will be appreciated?
Thanks,
The Gun
What I have so far:
Private Sub RTB_Change()
RTB.Text = Replace(RTB.Text, "bob", "BOB"
End Sub
The text is returned to the box in reverse order. I tried the 'StrReverse' function, but that's when it got really strange.
I think what is happening is that when the new string is inserted into RTB.Text, that the cursor position remains in front of the text, rather than in the back, so it may be as simple as telling the cursor to go to the end of the text. However, I lack the knowhow to make that happen. Any help will be appreciated?
Thanks,
The Gun