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.

ow = incStartRow<br />

ElseIf (row > incStopRow) And (row < expStartRow) Then<br />

row = expStartRow<br />

ElseIf row > expStopRow Then<br />

row = incStartRow<br />

End If<br />

If Indx(row, col) ] Index Then<br />

txtCell(Indx(row, col)).SetFocus<br />

End If<br />

End Sub<br />

Private Sub txtCell_LostFocus(Indx As Integer)<br />

Call DisplayTotals<br />

End Sub<br />

SUMMARY<br />

1. For programming purposes, tabular data are most efficiently processed if stored<br />

in an array. The ranges of variable arrays are specified by Dim or ReDim statements.<br />

2. An array of labels, text boxes, or comm<strong>and</strong> buttons, referred to in general as a<br />

control array, can be created by assigning a value (usually zero) to the Index<br />

property of the control at design time. Additional elements of the control array<br />

are created either at design time by using Ctrl+C <strong>and</strong> Ctrl+V to copy the first<br />

element in the array or at run time by using the Load statement. New elements<br />

created in either way inherit all the properties of the first element except the<br />

Index, Visible (if created with Load), Top (when copied at design time), <strong>and</strong><br />

Left (when copied at design time) properties.<br />

3. Two of the best-known methods for ordering (or sorting) arrays are the bubble<br />

sort <strong>and</strong> the Shell sort.<br />

4. Any array can be searched sequentially to find the subscript associated with a<br />

sought-after value. Ordered arrays can be searched most efficiently by a binary<br />

search.<br />

5. A table can be effectively stored in a two-dimensional array.<br />

PROGRAMMING PROJECTS<br />

1. Table 6.9 contains some lengths in terms of feet. Write a program that displays<br />

the nine different units of measure, requests the unit to convert from, the unit to<br />

convert to, <strong>and</strong> the quantity to be converted, <strong>and</strong> then displays the converted<br />

quantity. A typical outcome is shown in Figure 6-13.<br />

TABLE 6.9<br />

Equivalent Lengths<br />

1 inch = .0833 foot 1 rod = 16.5 feet<br />

1 yard = 3 feet 1 furlong = 660 feet<br />

1 meter = 3.2815 feet 1 kilometer = 3281.5 feet<br />

1 fathom = 6 feet 1 mile = 5280 feet<br />

<strong>Programming</strong> Projects 209

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

Saved successfully!

Ooh no, something went wrong!