Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Public Sub AddHighlight(ByRef RichTextBox As RichTextBox, ByVal Command As String, ByVal color As Color)
  2.  
  3. If RichTextBox.Text.Length > 0 Then
  4. Dim selectStart As Integer = RichTextBox.SelectionStart
  5.  
  6. LockWindowUpdate(RichTextBox.Handle.ToInt32)
  7.  
  8. 'RichTextBox.Select(0, RichTextBox.Text.Length)
  9. 'RichTextBox.SelectionColor = color.Black
  10. 'RichTextBox.DeselectAll()
  11.  
  12. Dim pos As Integer = 0
  13.  
  14. Do While RichTextBox.Text.ToUpper.IndexOf(Command.ToUpper, pos) >= 0
  15. pos = RichTextBox.Text.ToUpper.IndexOf(Command.ToUpper, pos)
  16. RichTextBox.Select(pos, Command.Length)
  17. RichTextBox.SelectionColor = color
  18. pos += 1
  19. Loop
  20.  
  21. RichTextBox.SelectionStart = selectStart
  22. RichTextBox.SelectionLength = 0
  23. LockWindowUpdate(0)
  24. End If
  25.  
  26. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement