-
Recoloring Syntax
I've been looking around for this and I can't find an answer. Sometimes I'll find something that's close but not the full answer, and sometimes I'll be reading it and it'll be for a different language. So I'm gonna stop looking and ask here.
In my program, I open files and they appear in my richtextbox. How would I got about recoloring all instances of a single word inside that richtextbox?
Syrillia
-
Re: Recoloring Syntax
Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim found As Long
If KeyAscii = 13 Then
RichTextBox1.HideSelection = False
found = RichTextBox1.Find(Text1.Text, 0, , rtfWholeWord)
While found <> -1
RichTextBox1.SelColor = RGB(255, 0, 0)
found = RichTextBox1.Find(Text1.Text, found + 1, , rtfWholeWord)
Wend
End If
End Sub
-
1 Attachment(s)
Re: Recoloring Syntax
Nice code technorobbo but it will not work efficiently with Keypress 13
I have attached a very basic example on how to use it...
Hope this helps...
Note: If you want to capture keypress 13 (for enter) or Ctrl +V (if user pastes data in the RTB) or when user simply types it and want the coloring to happen automatically then there is a different set of codes that you need to follow... (Check out the Code Generator link in my signature... it follows that principle)
-
Re: Recoloring Syntax
Nice code , it definitely does what I often neglect to do. Show the possibilities.