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.

ground color <strong>and</strong> caption. Setting the background style of a label to transparent<br />

causes whatever is behind the label to remain visible; the background<br />

color of the label essentially becomes “see through.”<br />

(e) Font: Can be set to any of Windows’ fonts, such as Courier <strong>and</strong> Times New<br />

Roman. Two unusual fonts are Symbol <strong>and</strong> Wingdings. For instance, with<br />

the Wingdings font, pressing the keys for %, &, ‘, <strong>and</strong> J yield a bell, a book,<br />

a c<strong>and</strong>le, <strong>and</strong> a smiling face, respectively. To view the character sets for the<br />

different Windows’ fonts, click on the Start button, <strong>and</strong> successively select<br />

Programs, Accessories, <strong>and</strong> Character Map. Then click on Character Map<br />

or press the Enter key. After selecting a font, hold down the left mouse button<br />

on any character to enlarge it <strong>and</strong> obtain the keystroke that produces<br />

that character.<br />

9. When you click on a property in the Properties window, a description of the<br />

property appears just below the window. Additional information about many of<br />

the properties can be found in Appendix C. With the Learning, Professional,<br />

<strong>and</strong> Enterprise Editions of VB6.0 you can obtain very detailed (<strong>and</strong> somewhat<br />

advanced) information about a property by clicking on the property <strong>and</strong> pressing<br />

F1 for Help.<br />

10. Most properties can be set or altered with code as the program is running<br />

instead of being preset from the Properties window. For instance, a comm<strong>and</strong><br />

button can be made to disappear with a line such as Comm<strong>and</strong>1.Visible = False.<br />

See Section 2.2 for details.<br />

11. The BorderStyle <strong>and</strong> MultiLine properties of a text box can be set only from the<br />

Properties window. You cannot alter them during run time.<br />

12. Of the objects discussed in this section, only comm<strong>and</strong> buttons have true access<br />

keys.<br />

13. If you inadvertently double-click an object in a form, a window containing two<br />

lines of text will appear. (The first line begins Private Sub.) This is a code window<br />

<strong>and</strong> is discussed in the next section. To remove this window, click on its<br />

Close button.<br />

14. To enlarge (or decrease) the Project Container window, position the mouse cursor<br />

anywhere on the right or bottom edge <strong>and</strong> drag the mouse. To enlarge (or<br />

decrease) the form, select the form <strong>and</strong> drag one of its sizing h<strong>and</strong>les. Alternatively,<br />

you can enlarge either the Project Container window or the form by<br />

clicking on its Maximize button.<br />

15. We will always be selecting the St<strong>and</strong>ard EXE icon from the New Project window.<br />

2.2 VISUAL BASIC EVENTS<br />

When a <strong>Visual</strong> <strong>Basic</strong> program is run, a form <strong>and</strong> its controls appear on the screen. Normally,<br />

nothing happens until the user takes an action, such as clicking a control or pressing the Tab<br />

key. Such an action is called an event.<br />

The three steps to creating a <strong>Visual</strong> <strong>Basic</strong> program are as follows:<br />

1. Create the interface; that is, generate, position, <strong>and</strong> size the objects.<br />

2. Set properties; that is, set relevant properties for the objects.<br />

3. Write the code that executes when the events occur.<br />

This section is devoted to Step 3.<br />

<strong>Visual</strong> <strong>Basic</strong> Events 27

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

Saved successfully!

Ooh no, something went wrong!