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.

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

Dim amount As Single, nutWid As Single<br />

‘Display amount of each component<br />

picAnalysis.Cls<br />

picAnalysis.Print “This meal contains the”<br />

picAnalysis.Print “following quantities”<br />

picAnalysis.Print “of these nutritional”<br />

picAnalysis.Print “components:”<br />

picAnalysis.Print For col = 1 To 5<br />

amount = 0<br />

For row = 1 To 10<br />

amount = amount + quantity(row) * nutTable(row, col)<br />

Next row<br />

picAnalysis.Print nutName(col) & “:”; Tab(16); amount<br />

Next col<br />

End Sub<br />

[Run, type the following quantities into each text box, <strong>and</strong> click the comm<strong>and</strong> button.]<br />

COMMENT<br />

1. We can define three- (or higher-) dimensional arrays much as we do two-dimensional<br />

arrays. A three-dimensional array uses three subscripts, <strong>and</strong> the assignment<br />

of values requires a triple-nested loop. As an example, a meteorologist<br />

might use a three-dimensional array to record temperatures for various dates,<br />

times, <strong>and</strong> elevations. The array might be created by the statement<br />

Dim temps(1 To 31, 1 To 24, 0 To 14) As Single<br />

6.6 A CASE STUDY: CALCULATING WITH A<br />

SPREADSHEET<br />

Spreadsheets are one of the most popular types of software used on personal computers. A<br />

spreadsheet is a financial planning tool in which data are analyzed in a table of rows <strong>and</strong><br />

columns. Some of the items are entered by the user. Other items, often totals <strong>and</strong> balances, are<br />

calculated using the entered data. The outst<strong>and</strong>ing feature of electronic spreadsheets is their<br />

ability to recalculate an entire table after changes are made in some of the entered data, thereby<br />

allowing the user to determine the financial implications of various alternatives. This is<br />

called “What if?” analysis.

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

Saved successfully!

Ooh no, something went wrong!