Practice Exercise 13
Searching
 

The objective of this program is to gain experience using file access and searching techniques.


The text file referenced below contains a list of words, one word per line. Write a program that will read these words into a dynamic array. Once the list of words has been read in, condense the list by removing any duplicate occurrences of a word. You can use the following code snippet to read the words into your array:

ReDim WordList(1 To 100) As String
Dim Index As Integer

Open App.Path & "\wordlist.txt" For Input As #1

While Not EOF(1)
     Index = Index + 1
     Input #1, WordList(Index)
Wend
Close #1
ReDim Preserve WordList(1 To Index)

Once you have read in the list of words, build a list of unique words. Use a pair of nested for loops. The pseudo-code looks like:

for each word in the original word list
     for each word in the unique word list
          if the word in the original list is not equal to the word in the unique list
               add the word to the unique word list
     end of inner for
end of outer for

Use textboxes to display the original list, the list of unique list, and a count of the number of words in each list.

Here is the text file.  Be sure to copy it into the directory in which your program is stored.