This one follows on from an earlier query ("Colored Text in TextBox"), but I have a clearer idea of what I'm trying to do now, so I'll start a new thread.
I have a VB5 application containing a RichTextBox, into which I've imported a Rich Text document. That document contains some words which are in different colors to the others, for example:
"This is a keyword, whereas this is a comment."
I want to edit this document within the RichTextBox using a selection of buttons that I'll create, which will perform a number of predefined operations. These operations include such things as turning all instances of the word "comment" blue, stripping out all the tabs, inserting carriage-returns after all the semicolons, and things like that.
How do I perform such search-and-replace operations on rich text?
I've tried duplicating the VB functions that MS Word writes within a user-defined macro when I run a search-and-replace operation there, but I can't relate the VB code that is created there to what I am trying to do here. I've also tried using the Instr function to perform the same tasks with some success, but more often than not I end up making the file uninterpretable as rich text.
(For the record, I'm writing an application that will automatically tidy up code written in another language. I know I could probably do it entirely with MS Word macros, but there are other aspects of the problem which make it preferable to write it as a stand-alone VB application.)
Many thanks for any help received.
I have a VB5 application containing a RichTextBox, into which I've imported a Rich Text document. That document contains some words which are in different colors to the others, for example:
"This is a keyword, whereas this is a comment."
I want to edit this document within the RichTextBox using a selection of buttons that I'll create, which will perform a number of predefined operations. These operations include such things as turning all instances of the word "comment" blue, stripping out all the tabs, inserting carriage-returns after all the semicolons, and things like that.
How do I perform such search-and-replace operations on rich text?
I've tried duplicating the VB functions that MS Word writes within a user-defined macro when I run a search-and-replace operation there, but I can't relate the VB code that is created there to what I am trying to do here. I've also tried using the Instr function to perform the same tasks with some success, but more often than not I end up making the file uninterpretable as rich text.
(For the record, I'm writing an application that will automatically tidy up code written in another language. I know I could probably do it entirely with MS Word macros, but there are other aspects of the problem which make it preferable to write it as a stand-alone VB application.)
Many thanks for any help received.