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.

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

COMMENTS<br />

1. When selecting from a list, double-clicking has the same effect as clicking once<br />

<strong>and</strong> pressing Enter.<br />

2. On a form, the Tab key cycles through the objects that can get the focus, <strong>and</strong> in<br />

a dialog box, it cycles through the items.<br />

3. The form itself is also an object <strong>and</strong> has properties. For instance, you can<br />

change the text in the title bar with the Caption property. You can move the form<br />

by dragging the title bar of its Project Container window.<br />

4. The name of an object is used in code to refer to the object. By default, objects<br />

are given names like Text1 <strong>and</strong> Text2. You can use the Properties window to<br />

change the Name property of an object to a more suggestive name. (The Name<br />

property is always the first property in the list of properties. An object’s Name<br />

must start with a letter <strong>and</strong> can be a maximum of 40 characters. It can include<br />

numbers <strong>and</strong> underline (_) characters, but can’t include punctuation or spaces.)<br />

Also, Microsoft recommends that each name begin with a three-letter prefix<br />

that identifies the type of the control. See the table below. Beginning with Section<br />

2.2, we will use suggestive names <strong>and</strong> these prefixes whenever possible.<br />

Object Prefix Example<br />

comm<strong>and</strong> button cmd cmdComputeTotal<br />

form frm frmPayroll<br />

label lbl blInstructions<br />

picture box pic picClouds<br />

text box txt txtAddress<br />

5. The Name <strong>and</strong> Caption properties of a comm<strong>and</strong> button are both initially set to<br />

something like Comm<strong>and</strong>1. However, changing one of these properties does not<br />

affect the setting of the other property. Similarly for the Name <strong>and</strong> Caption<br />

properties of forms <strong>and</strong> labels, <strong>and</strong> for the Name <strong>and</strong> Text properties of text<br />

boxes.<br />

6. The color settings appear as strings of digits <strong>and</strong> letters preceded by &H <strong>and</strong><br />

trailed with &. Don’t concern yourself with the notation.<br />

7. Here are some fine points on the use of the Properties window.<br />

(a) Press Shift+Ctrl+letterkey to highlight the first property that begins with<br />

that letter. Successive pressings highlight successive properties that begin<br />

with that letter.<br />

(b) To change the selected object from the Properties window, click on the<br />

down-arrow icon at the right of the Object box of the Properties window.<br />

Then select the new object from the drop-down list.<br />

8. Some useful properties that have not been discussed are the following:<br />

(a) BorderStyle: Setting the BorderStyle to “0 – None” removes the border<br />

from an object.<br />

(b) Visible: Setting the Visible property to False hides an object when the program<br />

is run. The object can be made to reappear with code.<br />

(c) BackColor: Specifies the background color for a text box, label, picture<br />

box, or form. Also specifies the background color for a comm<strong>and</strong> button<br />

having the Style property set to “1 – Graphical.” (Such a comm<strong>and</strong> button<br />

can display a picture.)<br />

(d) BackStyle: The BackStyle property of a label is opaque by default. The rectangular<br />

region associated with the label is filled with the label’s back-

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

Saved successfully!

Ooh no, something went wrong!