P
Paul M
hi there,
i have some code that is meant to search a richtextbox for a string and
hilight it in red, however, it only hilights the first instance of the word
found..
any help appreciated.
Dim intStartPosition As Integer = 1
Do While InStr(intStartPosition, rtf.Text.ToLower, value.Trim.ToLower) >
0
ntStartPosition = InStr(intStartPosition, rtf.Text.ToLower,
value.Trim.ToLower) + value.Trim.Length
rtf.SelectionStart = InStr(rtf.Text.ToLower, value.Trim.ToLower) - 1
rtf.SelectionLength = value.Trim.Length
rtf.SelectionColor = System.Drawing.Color.Red
If Not rtf.SelectionFont Is Nothing Then
Dim currentFont As System.Drawing.Font = rtf.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle = FontStyle.Bold
rtf.SelectionFont = New Font(currentFont.FontFamily,
currentFont.Size, newFontStyle)
End If
Loop
i have some code that is meant to search a richtextbox for a string and
hilight it in red, however, it only hilights the first instance of the word
found..
any help appreciated.
Dim intStartPosition As Integer = 1
Do While InStr(intStartPosition, rtf.Text.ToLower, value.Trim.ToLower) >
0
ntStartPosition = InStr(intStartPosition, rtf.Text.ToLower,
value.Trim.ToLower) + value.Trim.Length
rtf.SelectionStart = InStr(rtf.Text.ToLower, value.Trim.ToLower) - 1
rtf.SelectionLength = value.Trim.Length
rtf.SelectionColor = System.Drawing.Color.Red
If Not rtf.SelectionFont Is Nothing Then
Dim currentFont As System.Drawing.Font = rtf.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle = FontStyle.Bold
rtf.SelectionFont = New Font(currentFont.FontFamily,
currentFont.Size, newFontStyle)
End If
Loop