Chapter 12. The Language Reference


This chapter documents the major Visual Basic language elements. The elements are arranged alphabetically; see Appendix A for a listing by category.

Several different types of language elements appear in this chapter.


Functions

The entry for each function includes basic syntax information, with the details of parameters and return values. This is followed by a functional description and usage information (in the "Description" and "Usage at a Glance" sections). Many function entries also include source code examples.

Each VB function is, in fact, a method, since it is a member of a particular class in the Microsoft.VisualBasic (or other) namespace. Each entry identifies the class in which the function appears.

Visual Basic supports both named and positional arguments for most functions , procedures, and methods. Functions, procedures, or methods that accept parameter arrays as arguments don't accept named arguments if the ParamArray parameter is present. Some functions are actually resolved at compile time (the data-conversion functions fall into this category) and do not accept named arguments. To use named arguments, consider the syntax of the Mid function, which has two required arguments and one optional argument.

     Mid(str As String, start As Long[, length As Long]) 

Using positional arguments, you might call the function as follows:

     smallPart = Mid(wholeString, 12, 10) 

The same function call using named arguments might appear as follows:

     smallPart = Mid(start:=12, str:=wholeString, length:=10) 

Since most functions accept named arguments, the entries in this chapter only indicate when a function or procedure does not support named arguments.

The "Version Differences" section found in some entries documents changes in usage for the entry between the different versions of Visual Basic, including Visual Basic 6.0, Visual Basic .NET 2002, Visual Basic .NET 2003, and Visual Basic 2005.


Procedures

Procedures are functions that don't return a value to the caller. Except for the absence of a return value, the same information is presented for procedures as for functions.


Statements

Visual Basic statements are not class members, do not support named arguments, and do not return a value. Aside from these three differences, the same information is presented for statements as for procedures and functions.


Directives

Visual Basic directives provide instruction to the VB compiler or to a .NET development environment such as Visual Studio. Like statements, they are not class members, do not support named arguments, and do not return a value. In general, the same information is presented for directives as for statements.


Classes and Objects

Entries for classes and objects identify the namespace to which the class belongs and indicate whether the class is directly creatable. If a class is creatable, a new instance of that class can be created by using the New keyword, as in:

     Dim unitedStates As New Collection 

In some cases, the entry for the class or object also includes a summary listing of the class's members.


Class Members (Properties, Methods, and Events)

Class members of particular interest or importance have their own separate entries. These entries generally contain the same level of detail as function entries.


Attributes

Attributes are classes derived from System.Attribute that allow you to store information with an assembly's metadata. This chapter includes only those attributes that Visual Basic programmers are most likely to use. Each attribute entry includes information about the attribute, its constructor, and its properties. Attribute properties can be used as optional named arguments in the constructor.




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net