Preface |
|
viii | |
Notes to the Student |
|
xv | |
|
List of Programming Case Studies |
|
|
xvi | |
|
Computers and Problem Solving: An Introduction |
|
|
|
|
1 | (1) |
|
|
1 | (1) |
|
Disadvantages of a Computer |
|
|
1 | (1) |
|
|
2 | (2) |
|
|
3 | (1) |
|
|
3 | (1) |
|
|
3 | (1) |
|
|
3 | (1) |
|
Central Processing Unit (CPU) |
|
|
3 | (1) |
|
|
4 | (4) |
|
|
5 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
|
7 | (1) |
|
|
8 | (1) |
|
The Stored Program Concept |
|
|
8 | (1) |
|
|
8 | (4) |
|
|
10 | (1) |
|
|
10 | (1) |
|
The Graphical User Interface |
|
|
11 | (1) |
|
The Compiler and the Interpreter |
|
|
12 | (1) |
|
Problem Solving and Program Development |
|
|
12 | (4) |
|
|
13 | (1) |
|
|
14 | (2) |
|
Additional Information on Personal Computers |
|
|
16 | (1) |
|
|
16 | (1) |
|
|
17 | (2) |
|
|
19 | (2) |
|
|
|
Creating a Qbasic Program |
|
|
21 | (3) |
|
General Characteristics of a QBasic Program |
|
|
21 | (1) |
|
|
22 | (1) |
|
Variable Names and Constants |
|
|
22 | (1) |
|
|
23 | (1) |
|
|
23 | (1) |
|
|
23 | (1) |
|
Some Relationships between Statements |
|
|
23 | (1) |
|
|
24 | (4) |
|
|
26 | (2) |
|
The Print and CLS Statements |
|
|
28 | (1) |
|
Clearing the Screen---The CLS Statement |
|
|
29 | (1) |
|
|
29 | (3) |
|
|
29 | (1) |
|
Documenting a Program---The REM Statement |
|
|
30 | (2) |
|
|
32 | (1) |
|
Multiple Statements per line |
|
|
32 | (1) |
|
Getting Acquainted with the QB Operating Environment |
|
|
32 | (3) |
|
Starting a QBasic Session |
|
|
32 | (1) |
|
|
33 | (2) |
|
|
35 | (1) |
|
Terminating a QBasic Session |
|
|
35 | (1) |
|
|
35 | (2) |
|
Executing Programs and Hard Copy Output |
|
|
37 | (3) |
|
Executing the Current Program |
|
|
37 | (1) |
|
Listing Program Lines on the Printer |
|
|
38 | (1) |
|
Listing a Portion of the Program on the Printer |
|
|
39 | (1) |
|
Printing the Results on the Output Screen |
|
|
39 | (1) |
|
Saving, Loading, and Erasing Programs |
|
|
40 | (2) |
|
|
40 | (1) |
|
Saving the Current Program to Disk |
|
|
40 | (1) |
|
Loading a Program from Disk |
|
|
41 | (1) |
|
|
42 | (1) |
|
The QB Survival Guide Online Help System |
|
|
42 | (1) |
|
A Guide to Writing your First Program |
|
|
43 | (3) |
|
|
46 | (2) |
|
|
48 | (2) |
|
QBasic Programming Problems |
|
|
50 | (5) |
|
Calculations, Strings, and an Introduction to the Top-Down Approach |
|
|
|
|
55 | (1) |
|
|
56 | (4) |
|
|
56 | (1) |
|
Numeric Constants in Exponential Form |
|
|
57 | (1) |
|
Type and Range of Numeric Constants |
|
|
58 | (1) |
|
|
59 | (1) |
|
|
60 | (2) |
|
Selection of Variable Names |
|
|
61 | (1) |
|
|
62 | (1) |
|
|
62 | (3) |
|
|
65 | (8) |
|
Formation of Numeric Expressions |
|
|
65 | (1) |
|
Evaluation of Numeric Expressions |
|
|
66 | (1) |
|
The Effect of Parentheses in the Evaluation of Numeric Expressions |
|
|
67 | (2) |
|
Construction of Error-Free Numeric Expressions |
|
|
69 | (1) |
|
|
70 | (1) |
|
|
70 | (1) |
|
Developing a Rounding and Truncation Procedure |
|
|
70 | (1) |
|
|
71 | (1) |
|
Use of LEFT$, LEN, MID$, and RIGHT$ String Functions |
|
|
72 | (1) |
|
The Top-Down (Modular) Approach and the Gosub and Return Statements |
|
|
73 | (9) |
|
|
74 | (1) |
|
|
74 | (2) |
|
|
76 | (1) |
|
Implementing a Top-Down Design Using Subroutines (Modules) |
|
|
76 | (1) |
|
The GOSUB and RETURN Statements |
|
|
77 | (2) |
|
Recommended Style and Tips When Using the Top-Down Approach |
|
|
79 | (1) |
|
|
79 | (1) |
|
Flowchart Representation of GOSUB, RETURN, and Referenced Subroutine |
|
|
79 | (1) |
|
|
80 | (2) |
|
|
82 | (1) |
|
|
82 | (2) |
|
|
84 | (4) |
|
QBasic Programming Problems |
|
|
88 | (7) |
|
|
|
|
95 | (5) |
|
Testing for the End-of-File |
|
|
99 | (1) |
|
The do and Loop Statements |
|
|
100 | (3) |
|
Selecting the Proper Do Loop for a Program |
|
|
101 | (1) |
|
|
101 | (2) |
|
The Read, Data, and Restore Statements |
|
|
103 | (4) |
|
|
103 | (1) |
|
|
104 | (2) |
|
|
106 | (1) |
|
|
107 | (5) |
|
Print Zones and Print Positions |
|
|
108 | (1) |
|
Representation of Numeric Output |
|
|
108 | (1) |
|
Representation of String Output |
|
|
108 | (1) |
|
Use of the Comma Separator |
|
|
108 | (1) |
|
Use of the Semicolon Separator |
|
|
109 | (1) |
|
|
109 | (1) |
|
|
109 | (1) |
|
Displaying Spaces --- The SPC Function |
|
|
110 | (1) |
|
Calculations within the PRINT Statement |
|
|
110 | (1) |
|
Using the Immediate Window |
|
|
111 | (1) |
|
|
111 | (1) |
|
The Print Using Statement for Formatted Output |
|
|
112 | (14) |
|
Declaring the Format of the Output |
|
|
113 | (1) |
|
|
113 | (1) |
|
|
113 | (3) |
|
The Decimal Point (Period) Symbol |
|
|
116 | (1) |
|
|
116 | (1) |
|
The Plus and Minus Sign Symbols |
|
|
117 | (1) |
|
|
118 | (1) |
|
|
118 | (1) |
|
Formatted Character String Output |
|
|
119 | (2) |
|
The LPRINT USING Statement |
|
|
121 | (5) |
|
|
126 | (5) |
|
|
131 | (1) |
|
|
132 | (4) |
|
QBasic Programming Problems |
|
|
136 | (7) |
|
Structured Programming and Menu-Driven Programs |
|
|
|
|
143 | (2) |
|
|
144 | (1) |
|
|
145 | (1) |
|
Top-Down versus Structured |
|
|
145 | (1) |
|
|
145 | (4) |
|
Comparing Numeric Expressions |
|
|
147 | (1) |
|
Comparing String Expressions |
|
|
147 | (1) |
|
|
148 | (1) |
|
|
149 | (6) |
|
|
149 | (1) |
|
|
149 | (5) |
|
|
154 | (1) |
|
Implementing the Do-While and Do-Until Structures |
|
|
155 | (1) |
|
The WHILE and WEND Statements |
|
|
156 | (1) |
|
Implementing the If-Then-Else Structure |
|
|
156 | (4) |
|
Simple Forms of the If-Then-Else Structure |
|
|
156 | (2) |
|
Nested Forms of the If-Then-Else Structure |
|
|
158 | (2) |
|
|
160 | (6) |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
162 | (1) |
|
The XOR, EQV, and IMP Logical Operators |
|
|
163 | (1) |
|
|
164 | (1) |
|
Combining Logical Operators |
|
|
164 | (1) |
|
The Effect of Parentheses in the Evaluation of Compound Conditions |
|
|
165 | (1) |
|
Data-Validation Techniques |
|
|
166 | (3) |
|
|
166 | (1) |
|
|
167 | (1) |
|
|
167 | (1) |
|
|
168 | (1) |
|
|
168 | (1) |
|
The Select Case Statement and Menu-Driven Programs |
|
|
169 | (12) |
|
|
172 | (9) |
|
|
181 | (1) |
|
|
182 | (6) |
|
QBasic Programming Problems |
|
|
188 | (9) |
|
Sequential Files, Paging Reports, and Control-Break Processing |
|
|
|
|
197 | (1) |
|
|
197 | (2) |
|
|
199 | (1) |
|
Sequential File Processing |
|
|
199 | (14) |
|
|
199 | (2) |
|
|
201 | (1) |
|
Writing Reports to a Sequential File |
|
|
202 | (4) |
|
Flowchart of the OPEN and CLOSE Statements |
|
|
206 | (1) |
|
Writing Data to a Sequential File |
|
|
206 | (5) |
|
The INPUT #n Statement |
|
|
211 | (1) |
|
|
212 | (1) |
|
|
213 | (6) |
|
Paging Output on the Screen |
|
|
218 | (1) |
|
|
219 | (11) |
|
|
230 | (1) |
|
|
231 | (2) |
|
QBasic Programming Problems |
|
|
233 | (8) |
|
FOR Loops, Arrays, Sorting, and Table Processing |
|
|
|
|
241 | (1) |
|
The For and Next Statements |
|
|
242 | (11) |
|
The Do-While Loop versus the For Loop |
|
|
242 | (1) |
|
The Execution of a For Loop |
|
|
242 | (2) |
|
Flowchart Representation of a For Loop |
|
|
244 | (1) |
|
Valid Values in the FOR Statement |
|
|
244 | (1) |
|
|
245 | (1) |
|
Stepping by a Value Other than I |
|
|
246 | (1) |
|
Initializing the Loop Variable to a Value Other than I |
|
|
246 | (1) |
|
Decimal Fraction Values in a FOR Statement |
|
|
246 | (1) |
|
Negative Values in a FOR Statement |
|
|
246 | (1) |
|
Variables in a FOR Statement |
|
|
246 | (1) |
|
Expressions as Values in a FOR Statement |
|
|
247 | (1) |
|
Initial Entry into a For Loop |
|
|
247 | (1) |
|
Redefining For Loop Values |
|
|
247 | (1) |
|
Exiting a For Loop Prematurely---the EXIT Statement |
|
|
248 | (1) |
|
|
249 | (1) |
|
Another Look at the For Loop |
|
|
250 | (1) |
|
|
250 | (2) |
|
Valid Nesting of For Loops |
|
|
252 | (1) |
|
Arrays Versus Simple Variables |
|
|
253 | (1) |
|
|
254 | (3) |
|
|
254 | (2) |
|
The OPTION BASE Statement |
|
|
256 | (1) |
|
Dynamic Allocation of Arrays |
|
|
256 | (1) |
|
|
257 | (7) |
|
|
257 | (1) |
|
Summing the Elements of an Array |
|
|
258 | (6) |
|
|
264 | (3) |
|
Manipulating Two-Dimensional Arrays |
|
|
264 | (1) |
|
|
265 | (1) |
|
Arrays with More than Two Dimensions |
|
|
265 | (1) |
|
Determining the Lower- and Upper-Bound Subscript Values of an Array |
|
|
266 | (1) |
|
|
267 | (7) |
|
|
268 | (1) |
|
|
269 | (1) |
|
Implementing the Bubble Sort |
|
|
269 | (3) |
|
|
272 | (2) |
|
|
274 | (11) |
|
|
274 | (1) |
|
Positionally-Organized Tables |
|
|
274 | (2) |
|
Argument-Organized Tables |
|
|
276 | (1) |
|
|
277 | (3) |
|
Ordering the Table Arguments for a Serial Search |
|
|
280 | (1) |
|
|
281 | (3) |
|
Combining Table-Access Methods |
|
|
284 | (1) |
|
Some Formulae for Searching |
|
|
284 | (1) |
|
|
285 | (2) |
|
|
287 | (5) |
|
QBasic Programming Problems |
|
|
292 | (7) |
|
More on Strings and Functions |
|
|
|
|
299 | (1) |
|
String Functions and Statements |
|
|
299 | (17) |
|
Concatenation, Substrings, and Character Counting Revisited --- +, LEN, LEFT$, RIGHT$, and MID$ Functions |
|
|
300 | (3) |
|
Substring Searching and Replacement --- INSTR Function and MID$ Statement |
|
|
303 | (2) |
|
Converting Character Codes --- ASC and CHR$ Functions |
|
|
305 | (1) |
|
Changing Case --- LCASE$ and UCASE$ Functions |
|
|
306 | (2) |
|
Modifying Data Types --- STR$ and VAL Functions |
|
|
308 | (1) |
|
Duplicating Strings --- SPACE$ and STRING$ Functions |
|
|
309 | (1) |
|
Trimming Blank Characters --- LTRIM$ and RTRIM$ Functions |
|
|
309 | (1) |
|
Accessing the System Time and Date --- DATE$ and TIME$ Functions |
|
|
310 | (4) |
|
Setting the Time and Date --- DATE$ and TIME$ Statements |
|
|
314 | (1) |
|
Accepting String Data --- LINE INPUT Statement, INKEY$ and INPUT$ Functions |
|
|
314 | (2) |
|
|
316 | (13) |
|
Arithmetic Functions --- ABS, FIX, INT, CINT, and SGN |
|
|
317 | (1) |
|
Generalized Procedures for Rounding and Truncation |
|
|
318 | (1) |
|
Exponential Functions --- SQR, EXP, and LOG |
|
|
318 | (4) |
|
Trigonometric Functions --- SIN, COS, TAN, and ATN |
|
|
322 | (1) |
|
Utility Functions --- POS, CSRLIN, and SCREEN |
|
|
322 | (1) |
|
Performance Testing --- TIMER Function |
|
|
323 | (1) |
|
Random Number Function and the RANDOMIZE Statement |
|
|
324 | (5) |
|
|
329 | (6) |
|
|
329 | (2) |
|
Referencing User-Defined Functions |
|
|
331 | (4) |
|
|
335 | (2) |
|
|
337 | (1) |
|
|
337 | (4) |
|
QBasic Programming Problems |
|
|
341 | (8) |
|
File Maintenance, Random File Processing, and Simulated-Indexed Files |
|
|
|
|
349 | (1) |
|
|
349 | (1) |
|
|
349 | (1) |
|
|
350 | (14) |
|
|
364 | (11) |
|
Opening and Closing Random Files |
|
|
364 | (1) |
|
Creating the Record Structure for a Random File --- The TYPE Statement |
|
|
365 | (2) |
|
The GET and PUT Statements |
|
|
367 | (1) |
|
The LOC and LOF Functions |
|
|
368 | (7) |
|
|
375 | (14) |
|
Part 1 Tasks: Build Index File |
|
|
376 | (3) |
|
Part 2: Displaying and Updating Records in the Simulated-Indexed File |
|
|
379 | (10) |
|
|
389 | (1) |
|
|
390 | (1) |
|
QBasic Programming Problems |
|
|
391 | (6) |
|
Computer Graphics and Sound |
|
|
|
|
397 | (6) |
|
|
399 | (2) |
|
The SCREEN and WIDTH Statements |
|
|
401 | (1) |
|
|
402 | (1) |
|
|
403 | (15) |
|
The COLOR Statement for Text Mode |
|
|
411 | (3) |
|
Suspending Execution of a Program |
|
|
414 | (4) |
|
Medium-Resolution and High-Resolution Graphics |
|
|
418 | (19) |
|
The COLOR Statement for Medium-Resolution Graphics Mode |
|
|
419 | (1) |
|
The PSET and PRESET Statements |
|
|
420 | (1) |
|
|
421 | (2) |
|
|
423 | (2) |
|
|
425 | (1) |
|
|
426 | (2) |
|
|
428 | (3) |
|
|
431 | (1) |
|
The PMAP and POINT Functions |
|
|
432 | (2) |
|
|
434 | (1) |
|
The GET and PUT Statements for Graphics |
|
|
435 | (2) |
|
|
437 | (3) |
|
|
438 | (1) |
|
|
439 | (1) |
|
|
440 | (2) |
|
|
442 | (5) |
|
QBasic Programming Problems |
|
|
447 | (6) |
|
Subprograms, Functions, and Chaining |
|
|
|
|
453 | (1) |
|
|
453 | (10) |
|
Subroutines versus Subprograms |
|
|
453 | (2) |
|
|
455 | (1) |
|
|
455 | (1) |
|
Passing No Values to a Subprogram |
|
|
456 | (1) |
|
Passing Constants and Expressions |
|
|
456 | (2) |
|
Passing Variables and Individual Array Elements |
|
|
458 | (1) |
|
|
459 | (1) |
|
Passing Values between Subprograms |
|
|
460 | (1) |
|
Sharing Variables with Individual Subprograms |
|
|
460 | (2) |
|
Sharing Variables with All Associated Subprograms |
|
|
462 | (1) |
|
Using the QBasic Editor to Enter Subprograms |
|
|
463 | (6) |
|
|
465 | (2) |
|
Splitting the View Window |
|
|
467 | (1) |
|
Saving, Loading, and Executing the Main Program and Associated Subprograms |
|
|
468 | (1) |
|
Printing the Main Program and Associated Subprograms |
|
|
468 | (1) |
|
|
469 | (8) |
|
An Example of a Recursive Function |
|
|
471 | (2) |
|
Using the QBasic Editor to Enter Functions |
|
|
473 | (4) |
|
|
477 | (2) |
|
|
479 | (1) |
|
|
480 | (2) |
|
QBasic Programming Problems |
|
|
482 | (1) |
|
An Introduction to Visual Basic |
|
|
|
|
483 | (1) |
|
The Three-Step Approach to Building Applications with Visual Basic |
|
|
484 | (5) |
|
|
484 | (1) |
|
|
485 | (1) |
|
|
486 | (2) |
|
|
488 | (1) |
|
|
489 | (1) |
|
The Visual Basic Environment |
|
|
489 | (2) |
|
Building a Currency Conversion Application |
|
|
491 | (1) |
|
Creating the Interface for the Currency Application |
|
|
491 | (5) |
|
Setting the Size of a Form |
|
|
492 | (1) |
|
|
493 | (1) |
|
Adding and Removing Controls |
|
|
493 | (3) |
|
Changing the Location and Size of Controls |
|
|
496 | (1) |
|
Setting Properties for the Currency Application |
|
|
496 | (4) |
|
|
496 | (1) |
|
|
497 | (1) |
|
|
498 | (1) |
|
|
498 | (2) |
|
Writing Code for the Currency Conversion Application |
|
|
500 | (1) |
|
Saving a Visual Basic Project |
|
|
501 | (1) |
|
Starting, Opening, and Running Projects |
|
|
502 | (2) |
|
|
503 | (1) |
|
|
503 | (1) |
|
|
504 | (1) |
|
|
504 | (1) |
|
|
504 | (1) |
|
Visual Basic Application Problems |
|
|
505 | (2) |
Appendix A Program Design Tools --- Flowcharts, Pseudocode, Nassi-Schneiderman Charts, and Warnier-Orr diagrams |
|
|
|
507 | (3) |
|
|
507 | (1) |
|
|
507 | (3) |
|
A.2 Guidelines for Preparation of Flowcharts |
|
|
510 | (2) |
|
|
510 | (1) |
|
|
510 | (2) |
|
|
512 | (2) |
|
|
514 | (1) |
|
|
514 | (2) |
|
|
516 | (2) |
|
A.7 Nassi-Schneiderman Charts |
|
|
518 | (1) |
|
|
519 | (2) |
|
A.9 Test Your QBasic Skills |
|
|
521 | (4) |
Appendix B Menu Commands and Windows |
|
|
|
525 | (1) |
|
|
526 | (6) |
|
|
526 | (1) |
|
|
527 | (1) |
|
|
527 | (1) |
|
|
528 | (1) |
|
|
529 | (1) |
|
|
529 | (1) |
|
|
530 | (1) |
|
|
531 | (1) |
|
B.3 Using Windows to Your Advantage |
|
|
532 | (1) |
|
Changing the Active Window |
|
|
532 | (1) |
|
|
532 | (1) |
|
Scrolling in the Active Window |
|
|
532 | (1) |
Appendix C QBasic Debugging Techniques and Programming Tips |
|
|
|
533 | (2) |
|
Examining Values through the Immediate Window |
|
|
533 | (1) |
|
Executing One Statement At a Time |
|
|
534 | (1) |
|
|
534 | (1) |
|
|
535 | (1) |
|
|
535 | (1) |
|
C.2 Trapping User Errors (On Error Goto and Resume) |
|
|
535 | (4) |
|
|
539 | (2) |
|
|
541 | (2) |
Appendix D ASCII Character Set and Personal Computer Literature and Web Sites |
|
|
D.1 ASCII Character Codes |
|
|
543 | (1) |
|
D.2 Personal Computer Magazines, Newspapers, and Urls |
|
|
543 | (4) |
|
Personal Computer Magazines |
|
|
545 | (1) |
|
Personal Computer Newspapers |
|
|
545 | (1) |
|
|
545 | (2) |
Appendix E Answers to the Even-Numbered Test Your QBasic Skills Exercises |
|
547 | (18) |
Index |
|
565 | |
QBasic Reference Card |
|
R.I | |