• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1012
  • Last Modified:

RichtextBox Formating in VB6

I am creating a project in VB6.0 in which I am using a RTB (RichTextBox). In this RTB i am opening a RTF File which has multi color Texts. Now I want to Replace the Black Foreground Colored texts into Red Colored Texts. But I dont know how to do it.

Note:- This Black foreground Color is the Default Color. So there is no RTF value like \cf0

My Question is "How to Replace a certain Colored Text into Another Colored in RTB in vb6.0"

  • 2
1 Solution
Hi John,

  Check the below link


John-Paul75Author Commented:
Actually I have solved my problem. But your code is helpful to me. Thanks
I don't think you can locate sections of text by just knowing a font property.
To change the font.color of a section of text, I think you have to first 'select' the section.. That means you have to know why those sections you are referring to are that color. (spelling mistakes or a section the user has manually selected.)
If the text is not thousands of characters, you could scan thru the text one selected character at a time and tabulate a map of the colored sections you are interested in.. Then, from that map, select each section in turn and set its color. (This would be too slow on long text) (Tip.. making a Listbox or RTBox invisible while you perform actions like this greatly speeds up the process.)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now