19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

238 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

TABLE 7.5<br />

Final 1998 American League East St<strong>and</strong>ings<br />

American League East<br />

W L Pct<br />

New York 114 48 .704<br />

Boston 92 70 .568<br />

Toronto 88 74 .543<br />

Baltimore 79 83 .488<br />

Tampa Bay 63 99 .389<br />

3. Write a rudimentary word processing program. The program should do the following:<br />

(a) Use InputBox to request the name of the sequential file to hold the document<br />

being created.<br />

(b) Set the label for a text box to “Enter Line 1” <strong>and</strong> allow the user to enter the<br />

first line of the document into a text box.<br />

(c) When the Enter key is pressed or a “Record Line” comm<strong>and</strong> button is<br />

clicked, determine if the line is acceptable. Blank lines are acceptable input,<br />

but lines exceeding 60 characters in length should not be accepted. Advise<br />

the user of the problem with a message box, <strong>and</strong> then set the focus back to<br />

the text box so that the user can edit the line to an acceptable length.<br />

(d) When an acceptable line is entered, write this line to the file <strong>and</strong> display it<br />

in a picture box.<br />

(e) Change the prompt to “Enter Line 2”, clear the text box, allow the user to<br />

enter the second line of the document into the text box, <strong>and</strong> carry out (c) for<br />

this line using the same picture box. (Determine in advance how many lines<br />

the picture box can display <strong>and</strong> only clear the picture box when the lines<br />

already displayed do not leave room for a new line.)<br />

(f) Continue as in (d) with appropriate labels for subsequent lines until the user<br />

clicks on a “Finished” comm<strong>and</strong> button.<br />

(g) Clear the picture box <strong>and</strong> display the number of lines written <strong>and</strong> the name<br />

of the data file created.<br />

4. Write a program that counts the number of times a word occurs in the sequential<br />

file created in <strong>Programming</strong> Project 3. The file name <strong>and</strong> word should be<br />

read from text boxes. The search should not be sensitive to the case of the letters.<br />

For instance, opening a file that contained the first three sentences of the<br />

directions to this problem <strong>and</strong> searching for “the” would produce the output:<br />

“the” occurs six times.<br />

5. Create <strong>and</strong> Maintain Telephone Directories. Write a program to create <strong>and</strong><br />

maintain telephone directories. Each directory will be a separate sequential file.<br />

The following comm<strong>and</strong> buttons should be available:<br />

(a) Select a directory to access. A list of directories that have been created<br />

should be stored in a separate sequential file. When a request is made to<br />

open a directory, the list of available directories should be displayed as part<br />

of an InputBox prompt requesting the name of the directory to be accessed.<br />

If the user responds with a directory name not listed, the desire to create a<br />

new directory should be confirmed, <strong>and</strong> then the new directory created <strong>and</strong><br />

added to the list of existing directories.<br />

(b) Add name <strong>and</strong> phone number (as given in the text boxes) to the end of the<br />

current directory.<br />

(c) Delete name (as given in the text box) from the current directory.<br />

(d) Sort the current directory into name order.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!