Highlight words in RichTextBox using this simple function. This function requires 3 parameters to w
Highlight words in RichTextBox using this simple function. This function requires 3 parameters to work, the RichTextBox as an object, the word
API Declarations
'This is highlight all occurances of paramter 2
'LockWindowUpdate used to prevent flickering as text is highlighted
Private Declare Function LockWindowUpdate Lib "user32" (ByVal thWnd As Long) As Long
Rate Highlight words in RichTextBox using this simple function. This function requires 3 parameters to w
(1(1 Vote))
Dim cStart As Long: cStart = 1
With tRich
LockWindowUpdate .hWnd
Dim sStart As Long, sLen As Long: sStart = .SelStart: sLen = .SelLength
cStart = (InStr(cStart, LCase(.Text), tWord) - 1)
Do While cStart <> -1
.SelStart = cStart
.SelLength = Len(tWord)
.SelColor = tColor
If Len(.Text) > (cStart + Len(tWord)) Then
cStart = (InStr((cStart + Len(tWord)), LCase(.Text), tWord) - 1)
Else
cStart = -1
End If
Loop
.SelStart = sStart
.SelLength = sLen
LockWindowUpdate 0
End With
End Function
Highlight words in RichTextBox using this simple function. This function requires 3 parameters to w Comments
No comments yet — be the first to post one!
Post a Comment