Results 1 to 2 of 2

Thread: [resolved]highlight richtextbox?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2004
    Posts
    294

    Resolved [resolved]highlight richtextbox?

    i'm not sure how to call this code. what should i put for the "lColor" parameter?

    VB Code:
    1. Public Sub HighLight(RTB As RichTextBox, lColor As Long)
    2. 'add new color to color table
    3. 'add tags \highlight# and \highlight0
    4. 'where # is new color number
    5. Dim iPos As Long
    6. Dim strRTF As String
    7. Dim bkColor As Integer
    8.  
    9.     With RTB
    10.         iPos = .SelStart
    11.         'bracket selection
    12.         .SelText = Chr(&H9D) & .SelText & Chr(&H81)
    13.         strRTF = RTB.TextRTF
    14. 'add new color
    15.         bkColor = AddColorToTable(strRTF, lColor)
    16. 'add highlighting
    17.          strRTF = Replace(strRTF, "\'9d", "\up1\highlight" & CStr(bkColor) & "")
    18.          strRTF = Replace(strRTF, "\'81", "\highlight0\up0 ")
    19.  
    20.          .TextRTF = strRTF
    21.         .SelStart = iPos
    22.        End With
    23.  
    24. End Sub







    Added green "resolved" checkmark - Hack
    Last edited by Hack; Nov 15th, 2005 at 06:49 AM.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: highlight richtextbox?

    The color you want to use for the highlight. It can be one of the predefined color constants like vbRed, vbYellow, vbGreen and so on, or the result of a call to the RGB function, or the ForeColor/BackColor property of a control and so on.

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