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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

UNLOCK The Unlock comm<strong>and</strong> is intended for use in programs that operate on a network.<br />

After a Lock statement has been used to deny access to all or part of a file (see the discussion<br />

of Lock for details), a corresponding Unlock statement can be used to restore access.<br />

Suppose a data file has been opened as reference number n. The locks established by the<br />

statements Lock #n; Lock #n, r1; <strong>and</strong> Lock #n, r1 To r2 are undone by the statements Unlock<br />

#n; Unlock #n, r1; <strong>and</strong> Unlock #n, r1 To r2, respectively. There must be an exact correspondence<br />

between the locking <strong>and</strong> the unlocking statements used in a program, that is, each set<br />

of paired statements must refer to the same range of record numbers or bytes.<br />

UPDATE The Update method of a data control is used to save changes made to the database.<br />

VAL The Val function is used to convert strings to numbers. If the leading characters of the<br />

string str corresponds to a number, then Val(str) will be the number represented by these<br />

characters. For any number n, Val(Str(n)) is n.<br />

VALIDATE The Validate event procedure is activated whenever the current record of a database<br />

table is about to be changed. The heading of the procedure has the form Private Sub<br />

Data1_Validate(Action As Integer, Save As Integer), where the value of Action identifies the<br />

specific operation that triggered the event <strong>and</strong> the value of Save specifies whether data bound<br />

to the control has changed. You can change the value of the Action argument to convert one<br />

operation into another.<br />

VALUE The Value property of a scroll bar is a number between the values of the Min <strong>and</strong><br />

Max properties of the scroll bar that is related to the position of the thumb. The Value property<br />

of an option button is True when the button is on <strong>and</strong> False when the button is off. The<br />

Value property of a check box is 0 (unchecked), 1 (checked), or 2 (grayed). The Value property<br />

of Fields(“fieldName”) reads the contents of a field of the current record.<br />

VARIANT A variable of type variant can be assigned numbers, strings, <strong>and</strong> several other<br />

types of data. Variant variables are written without type-declaration tags. [variant]<br />

VARTYPE The value of the function VarType(var) is a number indicating the type of value<br />

stored in var. This function is primarily used to check the type of data stored in a variant variable.<br />

Some values returned by VarType are 0 for “Empty,” 1 for “Null,” 2 for Integer, 3 for<br />

Long Integer, 4 for Single Precision, 5 for Double Precision, 6 for Currency, 7 for Date, 8 for<br />

String, 9 for OLE Automation object, 10 for Error, 11 for Boolean, 13 for Non-OLE Automation<br />

object, <strong>and</strong> 17 for Byte. For nonvariant arrays, the number assigned is 8192 plus the<br />

number assigned to the type of the array. [variant]<br />

VISIBLE The property Visible determines whether or not a form or control is displayed. If<br />

the Visible property of an object is True, the object will be displayed (if not covered by other<br />

objects) <strong>and</strong> respond to events if its Enabled property is True. If the Visible property of an<br />

object is set to False, the object will not be displayed <strong>and</strong> cannot respond to events.<br />

WEEKDAY The value of the function WeekDay(d) is a number giving the day of the week<br />

for the date store in d. These values will range from 1 for Sunday to 7 for Saturday.<br />

WHILE/WEND A While ... Wend loop is a sequence of statements beginning with a statement<br />

of the form While condition <strong>and</strong> ending with the statement Wend. After the While statement<br />

is executed, the computer repeatedly executes the entire sequence of statements inside<br />

the loop as long as the condition is true.<br />

WIDTH (Property) The property Width determines the horizontal size of an object. Width<br />

is measured in units of twips. For the Printer object, Width may be read (pw = Printer.Width<br />

is OK) but not assigned (Printer.Width = 100 causes an error).<br />

WIDTH (Statement) If s is an integer less than 255 <strong>and</strong> n is the reference number of a file<br />

opened in sequential mode, the statement Width #n, s causes <strong>Visual</strong> <strong>Basic</strong> to permit at most<br />

s characters to be printed on a single line in the file. <strong>Visual</strong> <strong>Basic</strong> will send a carriagereturn/line-feed<br />

pair to the file after s characters have been printed on a line, even if the Print<br />

# or Write # statement would not otherwise start a new line at that point. The statement Width<br />

Appendix C 453

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

Saved successfully!

Ooh no, something went wrong!