I'm using this syntax checker and it works.
But this code will make my program run slowly.

Any suggestion?

(KeywordList and ObjectTagList are array.)

VB Code:
  1. Dim iPos As Integer
  2.     'save the current cursor position
  3.     iPos = rtfText.SelStart
  4.     'prevent the window from changing
  5.     LockWindowUpdate rtfText.hwnd
  6.     'clear all highlighted
  7.     rtfText.SelStart = 0
  8.     rtfText.SelLength = Len(rtfText.Text)
  9.     rtfText.SelColor = vbBlack
  10.     rtfText.SelBold = False
  11.     'Search over RTB
  12.     For i = 0 To Len(rtfText.Text) - 1
  13.         For s = 0 To UBound(KeywordList)
  14.             hlstr = KeywordList(s)
  15.             res = rtfText.Find(hlstr, i, Len(rtfText.Text), 14)
  16.                 If res <> -1 Then
  17.                     rtfText.SelStart = res
  18.                     rtfText.SelLength = Len(hlstr)
  19.                     rtfText.SelColor = vbBlue
  20.                 End If
  21.         Next
  22.     Next
  23.    
  24.     For i = 0 To Len(rtfText.Text) - 1
  25.         For s = 0 To UBound(ObjectTagList)
  26.             hlstr = ObjectTagList(s)
  27.             res = rtfText.Find(hlstr, i, Len(rtfText.Text), 14)
  28.                 If res <> -1 Then
  29.                     rtfText.SelStart = res
  30.                     rtfText.SelLength = Len(hlstr)
  31.                     rtfText.SelBold = True
  32.                 End If
  33.         Next
  34.     Next
  35.     'restore the cursor position
  36.     rtfText.SelStart = iPos
  37.     'unlock the window
  38.     LockWindowUpdate 0