RichtextBox Formating in VB6

Posted on 2011-04-24
Last Modified: 2012-05-11
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"

Question by:John-Paul75
    LVL 8

    Expert Comment

    Hi John,

      Check the below link

    LVL 8

    Accepted Solution


    Author Closing Comment

    Actually I have solved my problem. But your code is helpful to me. Thanks
    LVL 5

    Expert Comment

    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.)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now