Chapter 10. The Language Reference

   

This long chapter documents VB.NET language elements. To help you speed the process of finding the right element to perform a particular task, you can use Appendix B to determine what language elements are available for the purpose you require. If you're using Visual Studio .NET, you can also make use of its Object Browser to browse the Microsoft.VisualBasic namespace.

In documenting the VB.NET language, we've tried to provide a consistent and uniform treatment of particular types of language elements. These language elements are:

Functions

The entry for each function provides the standard information that you'd expect for a function: its syntax, parameters (if it has any), return value, and description. In addition, we list rules for using the function (see the "Rules at a Glance" section), discuss tips and tricks related to the function (see the "Programming Tips and Gotchas" section), frequently provide examples, and list related language elements.

In addition, each VB.NET function is in fact a method, since it is a member of a particular class in the Microsoft.VisualBasic namespace. In each case, we've listed the class to which the function belongs.

For the first time, Visual Basic supports both named and positional arguments for all functions, procedures, and methods, with just a few exceptions. Functions, procedures, or methods that accept parameter arrays as arguments don't accept named arguments if the ParamArray parameter is present. And "functions" that are actually resolved by the compiler at compile time (the conversion functions fall into this category) do not accept named arguments. To see how named arguments work, let's look at the syntax of the Mid function:

 Mid(Str As String, Start As Integer, Length As Integer) 

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

 iPos = Mid(strName, 12, 10) 

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

 iPos = Mid(start:=12, str:=strName, length:=10) 

Since named arguments are nearly universally accepted, we only note when you can't use named arguments with a particular function. The name of each argument is provided in the function's syntax statement.

Finally, we've noted any differences between the operation of the function under previous versions of Visual Basic and under VB.NET.

Procedures

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

Procedures are interesting as a separate language category. Under previous versions of Visual Basic, they were statements. With the rationalization and streamlining of Visual Basic for its .NET version, they were moved into classes in the Microsoft.VisualBasic namespace and became procedures. The official documentation describes them as functions, although they do not return a value.

Statements

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

Directives

Visual Basic directives are really statements that provide instructions to the VB.NET compiler or to a .NET development environment like Visual Studio. Like statements, they are not class members, don't support named arguments, and don't 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 (something that is particularly important in the case of the Framework Class Library) and indicate whether the class is createable. If a class is createable , a new instance of that class can be created by using the New keyword, as in:

 Dim colStates As New Collection() 

In some cases, the entry for the class or object also includes a summary listing of the class' members, along with their syntax and a brief description.

Class Members (Properties, Methods, and Events)

When the members of a class seem to be particularly interesting or important, we've devoted separate entries to each. These contain the same items of information as functions.

Attributes

Attributes are classes derived from System.Attribute that allow us to store information with an assembly's metadata. We've included only the attributes that VB programmers are most likely to use. The standard format for presenting information about attributes include some standard information (Class, Description, etc.), as well as the class constructors (these define the attribute's required arguments) and properties (which define the attribute's optional arguments).

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

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