VB Code:
Private Sub ChangeColor(ByVal word As String, ByVal clr As Color, ByVal rtb As RichTextBox, Optional ByVal start As Integer = 0) 'find word Dim ret As Integer = rtb.Find(word, start, RichTextBoxFinds.WholeWord) If ret > -1 Then rtb.SelectionColor = clr If ret < rtb.Text.Length Then ChangeColor(word, clr, rtb, ret + 1) End If End Sub 'syntax ChangeColor(txtWord.Text, Color.Blue, rtbText)
You could of course tie it to one RichTextBox or one color and cut out some of the parameters.




Reply With Quote