Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' The file path
  2. Dim FilePath As String = "test_document.txt"
  3.  
  4. ' Setup an array of strings
  5. Dim AllText() As String
  6.  
  7. ' Read all the lines of the file into the array
  8. AllText = File.ReadAllLines(FilePath)
  9.  
  10. ' Create your serach query. Replace 'traction' with what you want to search (remember to put the word(s) in "")
  11. Dim SearchQuery As String = "traction"
  12.  
  13. ' Whether the keyword has been found or not
  14. Dim QueryFound As Boolean = False
  15.  
  16. ' Loop through the array; this will go through each line
  17. ' of the text document and do stuff
  18. For i As Integer = 0 To AllText.Length - 1
  19.  
  20.     ' Check if this line has the word you're looking for
  21.    If AllText(i).Contains(SearchQuery) Then
  22.  
  23.         ' If this section is running, it means the keyword we're looking for
  24.        ' is in this line of text. Set the 'QueryFound' variable to true
  25.        QueryFound = True
  26.  
  27.     End If
  28.  
  29. Next
  30.  
  31. ' Log it to the console
  32. Console.WriteLine(FilePath + " contains '" + SearchQuery + "': " + (QueryFound.ToString()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement