Results 1 to 2 of 2

Thread: [RESOLVED] How to make text color in RichTextBox?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2007
    Posts
    227

    Resolved [RESOLVED] How to make text color in RichTextBox?

    Dear all expert programmer,
    Please tell me how to make text color in Richtextbox.

    If Ricctextbox have data below

    012-456-896

    I want to make 456 to red color but I don't know how to make it.

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: How to make text color in RichTextBox?

    This what you are looking for ?

    vb Code:
    1. Private Sub Command1_Click()
    2.  Dim lPos As Long
    3.  lPos = RichTextBox1.Find("896") 'Find the text
    4.  If lPos > -1 Then 'If found
    5.    RichTextBox1.SelStart = lPos 'Start selection
    6.    RichTextBox1.SelLength = 3 'select 3 chraters
    7.    RichTextBox1.SelColor = vbRed 'Color
    8.  End If
    9. End Sub
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width