Hi, I'm trying to read text in a window, like an AOL window, and I want to be able to read and pick out certain words in the textbox. I'm able to read the whole sentence, but I can't pick out any words in the sentence. Here is my code:

VB Code:
  1. ' Find the window.
  2. lHwnd = FindWindow(vbNullString, "vegric")
  3.    
  4. ' Find the chat box.
  5. lHwnd = FindWindowEx(lHwnd, ByVal 0&, "RichTextWndClass", vbNullString)
  6.    
  7. 'allocate a 255 byte string; the first two bytes indicate the length
  8. strBuff = Chr$(255) & String$(256, vbNullChar)
  9.  
  10. 'now this gets the last line of the textbox
  11. Call SendMessage(lHwnd, EM_GETLINE, SendMessage(lHwnd, EM_GETLINECOUNT, 0, ByVal 0&) - 2, ByVal StrPtr(strBuff))
  12.  
  13. 'convert the string to Unicode
  14. sWindowText = StrConv(strBuff, vbUnicode)
  15. MsgBox sWindowText
  16. 'below instead of saying 'if sWindowText = "hello"', I want to say something like if sWindowText CONTAINS "hello"
  17. If sWindowText = "hello" Then
  18. MsgBox ("The word 'hello' is in this sentence")
  19. End If

Thanks,
Brad