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.

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

picPercent.Print category; amount / total<br />

Input #1, category, amount<br />

picPercent.Print category; amount / total<br />

Close #1<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 />

Transportation 0.1739072<br />

Housing 0.3419534<br />

Food 0.1349828<br />

Other 0.3491566<br />

■ INPUT FROM AN INPUT BOX<br />

Normally, a text box is used to obtain input described by a label. Sometimes, we want just<br />

one piece of input <strong>and</strong> would rather not have a text box <strong>and</strong> label stay on the screen forever.<br />

The problem can be solved with an input box. When a statement of the form<br />

stringVar = InputBox(prompt, title)<br />

is executed, an input box similar to the one shown in Figure 2-25 pops up on the screen. After<br />

the user types a response into the text box at the bottom of the screen <strong>and</strong> presses Enter (or<br />

clicks OK), the response is assigned to the string variable. The title argument is optional <strong>and</strong><br />

gives the caption to appear in the Title bar. The prompt argument is a string that tells the user<br />

what information to type into the text box.<br />

FIGURE 2-25 Sample Input Box<br />

When you type the parenthesis following the word InputBox, the editor displays a line<br />

containing the general form of the InputBox statement. See Figure 2-26. This feature, which<br />

was added in <strong>Visual</strong> <strong>Basic</strong> 5.0, is called Quick Info. Optional parameters are surrounded by<br />

brackets. All the parameters in the general form of the InputBox statement are optional<br />

except for prompt.<br />

FIGURE 2-26 Quick Info Feature

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

Saved successfully!

Ooh no, something went wrong!