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.

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

#n, 0 specifies infinite width, that is, a carriage return/line feed pair will be sent to the printer<br />

only when requested by Print # or Write #.<br />

WITH/END WITH A multistatement block begun by With recName or With objName <strong>and</strong><br />

ended by End With is used to assign values to the fields of the named record variable or to<br />

properties of the named object. The statements inside the block have the form .fieldName =<br />

fieldValue or .propertyName = propertyValue. When you use this block, you only have to<br />

refer to the record variable or object once instead of referring to it with each assignment.<br />

WITHEVENTS If a class has events attached to it, <strong>and</strong> form code intends to make use of<br />

these events, then the keyword WithEvents should be inserted into the statement declaring an<br />

instance of the class. A typical declaration statement is Private WithEvents objectVariable As<br />

className.<br />

WORDWRAP The WordWrap property of a label with AutoSize property set to True determines<br />

whether or not long captions will wrap. (When a label’s AutoSize property is False,<br />

word wrap always occurs, but the additional lines will not be visible if the label is not tall<br />

enough.) Assume a label’s AutoSize property is True. If its WordWrap property is set to True,<br />

long captions will wrap to multiple lines; if its WordWrap property is False (the default), the<br />

caption will always occupy a single line. If a label has its WordWrap <strong>and</strong> AutoSize properties<br />

set to True, the label’s horizontal length is determined by the length of its longest word,<br />

with long captions being accommodated by having the label exp<strong>and</strong> vertically so that word<br />

wrap can spread the caption over several lines. If a label’s WordWrap property is set to False<br />

while its AutoSize property is True, the label will be one line high <strong>and</strong> will exp<strong>and</strong> or shrink<br />

horizontally to exactly accommodate its caption.<br />

WRITE # After a sequential file is opened for output or append with reference number n, the<br />

statement Write #n, exp1, exp2, . . . records the values of the expressions one after the other<br />

into the file. Strings appear surrounded by quotation marks, numbers do not have leading or<br />

trailing spaces, all commas in the expressions are recorded, <strong>and</strong> the characters for carriage<br />

return <strong>and</strong> line feed are placed following the data.<br />

XOR (Logical Operator) The logical expression condition1 Xor condition2 is true if condition1<br />

is true or condition2 is true, but not if both are true. For example, (3“a”) is false because both 3“a”are true, <strong>and</strong> (“apple”>“ape”) Xor<br />

(“earth”>“moon”) is true because “apple”>“ape”is true <strong>and</strong> “earth”>“moon”is false.<br />

XOR (Bitwise Operator) The expression byte1 Xor byte2 is evaluated by expressing each<br />

byte as an 8-tuple binary number <strong>and</strong> then Xoring together corresponding digits, where 1 Xor<br />

0 <strong>and</strong> 0 Xor 1 both equal 1, while 1 Xor 1 <strong>and</strong> 0 Xor 0 both equal 0. For example, the expression<br />

37 Xor 157 translated to binary 8-tuples becomes 00100101 Xor 10011101. Xoring<br />

together corresponding digits gives the binary 8-tuple 10111000 or decimal 184. Thus, 37<br />

Xor 157 is 184.<br />

YEAR The function Year extracts the year from a serial date. If d is any valid serial date, then<br />

the value of Year(d) is a whole number from 100 to 9999 giving the year recorded as part of<br />

the date <strong>and</strong> time stored in d. [date]<br />

SUPPORTING TOPICS<br />

[BINARY FILE]: A file that has been opened with a statement of the form Open “filespec”For<br />

Binary As #n is regarded simply as a sequence of characters occupying positions 1,<br />

2, 3, . . . . At any time, a specific location in the file is designated as the “current position.”<br />

The Seek statement can be used to set the current position. Collections of consecutive characters<br />

are written to <strong>and</strong> read from the file beginning at the current position with Put <strong>and</strong> Get<br />

statements, respectively. After a Put or Get statement is executed, the position following the<br />

last position accessed becomes the new current position.

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

Saved successfully!

Ooh no, something went wrong!