Hi, normally I'm using the code below to search for words in a text file and display the entire line when a match has been found.

VB Code:
  1. Private Sub Command1_Click()
  2. Dim sLines As String
  3.  
  4. Open "C:\textfile.txt" For Input As #1
  5.   Do While Not EOF(1)
  6.    Line Input #1, sLines
  7.     If InStr(1, sLines, "horse") And InStr(1, sLines, "fish") Then
  8.      Text1.Text = Text1.Text & sLines & vbCrLf
  9.     End If
  10.   DoEvents
  11.   Loop
  12. Close #1
  13.  
  14. End Sub
How can I do the same thing when I have the words (horse and fish) stored in an array? Normally I can replace "Horse" with strArray(0) and "Fish" with strArray(1), but the number of words in the array is always different.

In other words, how do I use an array with "If InStr(1, sLines, ????????) Then" when the amount of search words is always different?

(btw, the text file can be 50MB big)