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.

[COLOR]: Numbers written in base 16 are referred to as hexadecimal numbers. They are<br />

written with the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A (=10), B (=11), C (=12), D (=13), E (=14),<br />

<strong>and</strong> F (=15). A hexadecimal number such as rst corresponds to the decimal integer t + 16 *<br />

s + 16 * r. Each color in <strong>Visual</strong> <strong>Basic</strong> is identified by a long integer (usually expressed as a<br />

hexadecimal number of the form &H...&) <strong>and</strong> referred to as an RGB color number. This<br />

number specifies the amounts of red, green, <strong>and</strong> blue combined to produce the color. The<br />

amount of any color is a relative quantity, with 0 representing none of the color <strong>and</strong> 255 representing<br />

the maximum available. Thus, black corresponds to 0 units each of red, green, <strong>and</strong><br />

blue, <strong>and</strong> white corresponds to 255 units each of red, green, <strong>and</strong> blue. The RGB color number<br />

corresponding to r units of red, g units of green, <strong>and</strong> b units of blue is r + 256 * g + 65536<br />

* b, which is the value returned by the function RGB(r, g, b). Hexadecimal notation provides<br />

a fairly easy means of specifying RGB color numbers. If the amount of red desired is<br />

expressed as a two-digit hexadecimal number, rr, the amount of green in hexadecimal as gg,<br />

<strong>and</strong> the amount of blue in hexadecimal as bb, then the RGB color number for this color is<br />

&H00bbggrr&. For example, the RGB color number for a bright green would come from 255<br />

(FF in hexadecimal) units of green, so the RGB color number in hexadecimal is<br />

&H0000FF00&.<br />

[COORDINATE SYSTEMS]: The default coordinate system for a form, picture box, or the<br />

printer defines the upper-left corner as the point (0, 0). In this coordinate system, the point<br />

(x, y) lies x units to the right of <strong>and</strong> y units below the upper-left corner. The unit of measure<br />

in the default coordinate system is a twip. A twip is defined as 1/1440 of an inch (though<br />

varying screen sizes may result in 1440 twips not appearing as exactly an inch on the screen).<br />

Custom coordinate systems can be created using the Scale method <strong>and</strong> ScaleMode property.<br />

[DATE]: Functions dealing with dates <strong>and</strong> times use the type 7 variant data type. Dates <strong>and</strong><br />

times are stored as serial dates, double-precision numbers, with the whole part recording the<br />

date <strong>and</strong> the decimal part recording the time. Valid whole parts range from –657434 to<br />

2958465, which correspond to all days from January 1, 100 to December, 31, 9999. A whole<br />

part of 0 corresponds to December 30, 1899. All decimal parts are valid, with .0 corresponding<br />

to midnight, .25 corresponding to 6 a.m., .5 corresponding to noon, <strong>and</strong> so on. In<br />

general, the decimal equivalent of sec/86400 corresponds to sec seconds past midnight. If a<br />

given date corresponds to a negative whole part, then times on that day are obtained by<br />

adding a negative decimal part to the negative whole part. For example, October, 24, 1898,<br />

corresponds to a whole part of –432. A time of 6 p.m. corresponds to .75, so a time of 6 p.m.<br />

on 10/24/1898 corresponds to –432 +–.75 = –432.75.<br />

[DIRECTORIES]: Think of a disk as a master folder holding other folders, each of which<br />

might hold yet other folders. Each folder, other than the master folder, has a name. Each<br />

folder is identified by a path: a string beginning with a drive letter, a colon, <strong>and</strong> a backslash<br />

character, ending with the name of the folder to be identified, <strong>and</strong> listing the names of the<br />

intermediate folders (in order) separated by backslashes. For instance the path<br />

“C:\DAVID\GAMES” identifies the folder GAMES, which is contained in the folder<br />

DAVID, which in turn is contained in the master folder of drive C.<br />

Each folder is called a directory <strong>and</strong> the master folder is called the root directory. When<br />

a folder is opened, the revealed folders are referred to as its subdirectories. Think of a file as<br />

a piece of paper inside one of the folders. Thus, each directory contains files <strong>and</strong> subdirectories.<br />

[DYNAMIC VS. STATIC ARRAYS]: <strong>Visual</strong> <strong>Basic</strong> uses two methods of storing arrays:<br />

dynamic <strong>and</strong> static. The memory locations for a static array are set aside the instant the program<br />

is executed <strong>and</strong> this portion of memory may not be freed for any other purpose. The<br />

memory locations for a dynamic array are assigned when a particular procedure requests that<br />

an array be created (a Dim or ReDim statement is encountered) <strong>and</strong> can be freed for other<br />

purposes. Although dynamic arrays are more flexible, static arrays can be accessed faster.<br />

Arrays Dimensioned in the (Declarations) section of (General) use static allocation, except<br />

Appendix C 455

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

Saved successfully!

Ooh no, something went wrong!