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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Dim a As String, b As String, c As String, d As String<br />

a = “North”<br />

b = “to”<br />

c = “the”<br />

d = “future.”<br />

picBox.Print a, b, c, d<br />

picBox.Print “12345678901234567890123456789012345678901234567890”<br />

EXAMPLE 5<br />

The following program uses Print zones to organize expenses for public <strong>and</strong> private schools into columns<br />

of a table. The data represent the average expenses for 1995–96. (The Font setting for picTable is the<br />

default font MS Sans Serif.)<br />

Private Sub cmdDisplay_Click()<br />

picTable.Cls<br />

picTable.Print “ ”, “Pb 2-yr”, “Pr 2-yr”, “Pb 4-yr”, “Pr 4-yr”<br />

picTable.Print<br />

picTable.Print “Tuit & Fees”, 1387, 6350, 2860, 12432<br />

picTable.Print “Bks & Suppl”, 577, 567, 591, 601<br />

picTable.Print “Board”, 1752, 1796, 1721, 1845<br />

picTable.Print “Trans”, 894, 902, 929, 863<br />

picTable.Print “Other Exp”, 1142, 1220, 1348, 1169<br />

picTable.Print “ ”, “-------”, “-------”, “-------”, “-------”<br />

picTable.Print “Total”, 5752, 10835, 7449, 16910<br />

End Sub<br />

[Run <strong>and</strong> then click the comm<strong>and</strong> button. The following is displayed in the picture box.]<br />

Pb 2-yr Pr 2-yr Pb 4-yr Pr 4-yr<br />

Tuit & Fees 1387 6350 2860 12432<br />

Bks & Suppl 577 567 591 601<br />

Board 1752 1796 1721 1845<br />

Trans 894 902 929 863<br />

Other Exp 1142 1220 1348 1169<br />

------ ------ ------ ------<br />

Total 5752 10835 7449 16910<br />

■ TAB FUNCTION<br />

If an item appearing in a Print statement is preceded by<br />

Tab(n);<br />

where n is a positive integer, that item will be displayed (if possible) beginning at the nth position<br />

of the line. (Exceptions are discussed in Comment 10.)<br />

EXAMPLE 6<br />

The following program uses the Tab function to organize data into columns of a table. The data represent<br />

the number of bachelor’s degrees conferred (in units of 1000). (Source: National Center of Educational<br />

Statistics.)<br />

Private Sub cmdDisplay_Click()<br />

picTable.Cls<br />

picTable.Print Tab(10); “1970-71”; Tab(20); ”1980-81”; Tab(30); “1990-91”<br />

picTable.Print<br />

picTable.Print ”Male”; Tab(10); 476; Tab(20); 470; Tab(30); 490

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

Saved successfully!

Ooh no, something went wrong!