[resolved]highlight richtextbox?
i'm not sure how to call this code. what should i put for the "lColor" parameter?
VB Code:
Public Sub HighLight(RTB As RichTextBox, lColor As Long)
'add new color to color table
'add tags \highlight# and \highlight0
'where # is new color number
Dim iPos As Long
Dim strRTF As String
Dim bkColor As Integer
With RTB
iPos = .SelStart
'bracket selection
.SelText = Chr(&H9D) & .SelText & Chr(&H81)
strRTF = RTB.TextRTF
'add new color
bkColor = AddColorToTable(strRTF, lColor)
'add highlighting
strRTF = Replace(strRTF, "\'9d", "\up1\highlight" & CStr(bkColor) & "")
strRTF = Replace(strRTF, "\'81", "\highlight0\up0 ")
.TextRTF = strRTF
.SelStart = iPos
End With
End Sub
Added green "resolved" checkmark - Hack
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.