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.

DEFINT, DEFLNG, DEFSNG, DEFDBL, DEFSTR, DEFCUR, DEFVAR, DEFBYTE,<br />

DEFBOOL, DEFDATE, DEFOBJ A variable can be assigned a type by either a type-declaration<br />

tag or an As clause. A statement of the form DefInt letter specifies that any “untyped”<br />

variable whose name begins with the specified letter will have integer type. A statement of<br />

the form DefInt letter1-letter2 specifies that all “untyped” variables whose names begin with<br />

a letter in the range letter1 through letter2 will have integer type. The statements DefLng,<br />

DefSng, DefDbl, DefStr, DefCur, DefVar, DefByte, DefBool, DefDate, <strong>and</strong> DefObj specify<br />

the corresponding types for long integer, single-precision, double-precision, string, currency,<br />

variant, byte, boolean, date, <strong>and</strong> object variables, respectively. DefType statements are<br />

placed in the (Declarations) section of (General). [variant]<br />

DELETE The Delete method for a data control deletes the current record.<br />

DIM The statement Dim arrayName(m To n) As variableType declares an array with subscripts<br />

ranging from m to n, inclusive, where m <strong>and</strong> n are in the normal integer range of<br />

–32768 to 32767. The variableType must be Integer, Long, Single, Double, Currency, String,<br />

String*n, Variant, Boolean, Byte, Date, or a user-defined type. A statement of the form Dim<br />

arrayName(m To n, p To q) As variableType declares a doubly subscripted, or two-dimensional,<br />

array. Three- <strong>and</strong> higher-dimensional arrays are declared similarly. If m <strong>and</strong> p are<br />

zero, the preceding Dim statements may be changed to Dim arrayName(n) As variableType<br />

<strong>and</strong> Dim arrayName(n, q) As variableType. The statement Dim arrayName( ) As variable-<br />

Type defines an array whose size is initially unknown but must be established by a ReDim<br />

statement before the array can be accessed. The statement Dim variableName As variable-<br />

Type specifies the type of data that will be stored in variableName. Variables <strong>and</strong> arrays<br />

Dimmed in the (Declarations) section of (General) are available to all procedures. In procedures,<br />

Dim is used to declare variables, but ReDim is often used to dimension arrays.<br />

[dynamic vs. static] [variant]<br />

DIR If fileTemplate specifies a file (or a collection of files by including ? or *), then the<br />

value of the function Dir(fileTemplate) is the filename of the first file matching the pattern<br />

specified by fileTemplate. If this value is not the null string, the value of the function Dir is<br />

the name of the next file that matches the previously specified pattern. For example, the<br />

value of Dir(“*.VBP”) will be the name of the first file in the current directory of the default<br />

drive whose name has the .VBP extension. [directories] [filespec]<br />

DO/LOOP A statement of the form Do, Do While cond, or Do Until cond is used to mark<br />

the beginning of a block of statements that will be repeated. A statement of the form Loop,<br />

Loop While cond, or Loop Until cond is used to mark the end of the block. Each time a<br />

statement containing While or Until followed by a condition is encountered, the truth value<br />

of the condition determines whether the block should be repeated or whether the program<br />

should jump to the statement immediately following the block. A Do loop may also be exited<br />

at any point with an Exit Do statement.<br />

DOEVENTS Executing the statement DoEvents permits <strong>Visual</strong> <strong>Basic</strong> to act on any events<br />

may have occurred while the current event procedure has been executing.<br />

DOUBLE A variable of type Double requires 8 bytes of memory <strong>and</strong> can hold 0, the numbers<br />

from 4.9406520 � 2010 –324 to 1.797693134862316 � 10308 with at most 17 significant<br />

digits <strong>and</strong> the negatives of these numbers. Double values <strong>and</strong> variables may be indicated by<br />

the type tag #: 2.718281828459045#, Pi#.<br />

DRAWMODE The property DrawMode determines whether graphics are drawn in black,<br />

white, foreground color, or some interaction of these colors with the current contents of the<br />

form or picture box. The following table lists the allowed values for the DrawMode property<br />

<strong>and</strong> the rules for what RGB color number will be assigned at a given point when the RGB<br />

color number for the color currently displayed at that point is display <strong>and</strong> the RGB color<br />

number for the draw color is draw. [color]<br />

Appendix C 429

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

Saved successfully!

Ooh no, something went wrong!