Our teaching notes have an Index page with links to the Topic Note containing each key (boldface) term. I wrote a program to construct that Index page automatically. The program scans through each Topic Note looking for boldface terms. When it finds them, it enters them into an array with a link to the corresponding Topic Note file. When it has them all, they are sorted into alphabetic order and written into the Terms.htm file you see on the Web site.
The user interface is very simple. When the user clicks the Build button, the file is created and the number of terms and Topic Notes displayed:
I could have written this as one large event handler that was executed when the user clicked the Build button, but that would have been confusing. Instead, I broke it into five small subprograms. The event handler for the Build button calls each of them in order:
Private Sub BtnBuild_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBuild.Click Call GetFilenames () 'place the names of each note file in the FileNames array Call FindTerms () 'find the boldface terms in each file in FileNames and place them and the file name in Result Call SortResult () 'sort Result into alphabetical order Call OutputResult () 'create a Web page by writing the contents of Result to the file Terms.htm Call Close () 'display the number of records and terms and close Terms.htm End SubFrom this, you can see the overall program logic without getting lost in the details of how each subprogram works. You can focus your attention on what it does, not how it does it.
The subprograms communicate with each other by assigning values to four form-level global variables. (Their effects are to change the values of those variables).
The four global variables are:
Dim FileNames() As String 'path and name of each Topic Note file Dim Result(1, 500) As String 'boldface terms and corresponding path and file names Dim LastResult As Integer 'pointer to the last Result entry Dim LastHTM As Integer 'pointer to the last FileNames entryThe following are short descriptions of each subprogram: