Guest User

Untitled

a guest
Oct 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. Private Sub Write_code_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Write_code.TextChanged
  2. Dim strWord As String
  3. Dim lPos As Long
  4.  
  5. strWord = "read"
  6.  
  7. lPos = InStr(1, Write_code.Text, strWord, vbTextCompare)
  8.  
  9. If lPos > 0 Then
  10. With Write_code
  11. .SelectionStart = lPos - 1
  12. .SelectionLength = Len(strWord)
  13. .SelectionColor = Color.Green
  14. .SelectionStart = Len(Write_code.Text)
  15. .SelectionLength = 0
  16. .SelectionColor = Color.Blue
  17. End With
  18. End If
  19. End Sub
  20.  
  21. Private Sub Write_code_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Write_code.TextChanged
  22. Dim strWord As String
  23. Dim lPos As Long
  24.  
  25. strWord = "read"
  26.  
  27. lPos = InStr(1, Write_code.Text, strWord, vbTextCompare)
  28.  
  29. If lPos > 0 Then
  30. Dim originalPosition As Long = Write_code.SelectionStart
  31.  
  32. With Write_code
  33. .SelectionStart = lPos - 1
  34. .SelectionLength = Len(strWord)
  35. .SelectionColor = Color.Green
  36. .SelectionStart = Len(Write_code.Text) ' Or maybe put it here
  37. .SelectionLength = 0
  38. .SelectionColor = Color.Blue
  39. End With
  40.  
  41. Write_code.SelectionStart = originalPosition
  42. End If
  43. End Sub
Add Comment
Please, Sign In to add comment