Designing the Form

The program is divided into two parts: the first part contains the form used to update the data file and the second part contains the worksheet used to create a puzzle. Figure 7.16 shows the form's design from the IDE.

Whenever a program is required to display a list, you should immediately think List Box or Combo Box control. I have added a Combo Box control to the form for displaying the list of topics and a List Box control for displaying the list of words associated with a selected topic. That is, when the user changes the selection in the Combo Box control the list of words in the List Box control will also change to match the topic.

Combo Box control-

Topic

Command Button controls

Label control

Text Box controls

List Box control

Topic

Command Button controls

Design Time view of the form used for updating the Word Find program's data file.

■:::■ ■.:.„■.:■■„.:------------------------.:.-,-I"- „..:■■„...■, ■■,■.:■■„ ■.:.„■■:.,Vi

Label control

Although I have not previously discussed the Text Box control, you should find it fairly easy to use. It is a simple control that serves to collect textual input from a user. As with all controls, you should edit the Name and appearance (size, font, and so on) properties of the Text Box control at Design Time. The value of the Text property stores whatever is currently entered in the Text Box, so this property is frequently accessed in your programs. Other properties of interest include: MaxLength, MultiLine, PasswordChar, SpecialEffect, TextAlign, and WordWrap. You should take the time to familiarize yourself with the Text Box control and some of its properties. The Text Box controls I added to the form serve to display the currently selected topic and word. I have used Text Box controls instead of Label controls because the user must be able to enter new values into these controls.

The purpose of the form is to allow the user to enter new records or edit existing records stored in the Wordfind.txt data file. I added the Text Box and Command Button controls to the form in order to achieve this purpose. To add a new record, the user can enter a new word in the appropriate text box control with an existing topic, or the user can enter a new topic before clicking the Add New button. To edit an existing record, the user must first select a word from the List Box to enable the Update button. Next, the user can edit the word and click Update. When the Update button is clicked, the existing record will be overwritten in the data file.

The data from the file must also be added to a hidden worksheet. I decided to use the worksheet because I wanted to display the data alphabetically sorted; thus taking advantage of Excel's ability to quickly sort data. It also makes sense to store the data somewhere it can be quickly and easily accessed, yet still protected. A worksheet that is hidden from the user works quite well, although further protections should probably be added (password protection of the worksheet). It is also important that the data in the hidden worksheet be updated as the file is updated by the user.

I have left a couple of potential problems in the form's design. It does not protect against adding identical records to the data file, does not allow records to be deleted, and it does not allow the user to edit the name of an existing topic (in case of a misspelling). I have left the challenge of solving these limitations to the reader along with several other enhancements to the program (see the Challenges at the end of the chapter).

Biorhythm Awareness

Biorhythm Awareness

Who else wants to take advantage of biorhythm awareness to avoid premature death, escape life threatening diseases, eliminate most of your life altering mistakes and banish catastrophic events from your life.

Get My Free Ebook


Post a comment