Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' The file path
- Dim FilePath As String = "test_document.txt"
- ' Setup an array of strings
- Dim AllText() As String
- ' Read all the lines of the file into the array
- AllText = File.ReadAllLines(FilePath)
- ' Create your serach query. Replace 'traction' with what you want to search (remember to put the word(s) in "")
- Dim SearchQuery As String = "traction"
- ' Whether the keyword has been found or not
- Dim QueryFound As Boolean = False
- ' Loop through the array; this will go through each line
- ' of the text document and do stuff
- For i As Integer = 0 To AllText.Length - 1
- ' Check if this line has the word you're looking for
- If AllText(i).Contains(SearchQuery) Then
- ' If this section is running, it means the keyword we're looking for
- ' is in this line of text. Set the 'QueryFound' variable to true
- QueryFound = True
- End If
- Next
- ' Log it to the console
- Console.WriteLine(FilePath + " contains '" + SearchQuery + "': " + (QueryFound.ToString()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement