How change font in Rich Text Box?

Posted on 2006-03-27
Last Modified: 2013-12-03
I have a RichTextBox control on a vb 6 form.  When I load the RTF control from a file, I want some lines to be BOLD and UNDERLINE and other lines to be normal.

How do I do that?

Question by:EYoung

    Accepted Solution

    Hi EYoung

    Assuming you know the particular strings etc that you want to apply formatting to, you could do something like the following

    rtb.SelStart = 2
    rtb.SelLength = 5
    rtb.SelUnderline = True
    rtb.SelBold = True
    rtb.SelFontName = "Arial"

    After loading the file, you can use "InStr" to determine the SelStart value, and the length of the string to determine SelLength, then just apply the formatting using the Sel... methods.

    LVL 7

    Author Comment

    I'll be back at that client's offices tomorrow and will try the suggestions then.  Thanks

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    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…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    734 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

    20 Experts available now in Live!

    Get 1:1 Help Now