Practice Exercise 12

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:

Dim wordList(100) As String
index As Integer = 0
Dim outputString As String = ""

' process original list
While Not EOF(fileNumber)
    Input(fileNumber, wordList(index))
    outputString &= wordList(index) & vbCrLf
    index = index + 1
End While
Preserve wordList(index - 1)
txtOriginal.Text = outputString

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

for each word in the original word list
     if unique word list contains the current word in the original list
          add the word to the unique word list
     end if
end for

Use textboxes to display the original list, the list of unique list, and labels for 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.

Sample String

Demo/sln file