Functions


The syntax for writing a function is as follows:

  [attribute_list] [interitance_mode] [accessibility] _ Function function_name([parameters]) [As return_type] [ Implements interface.function ]     [ statements ] End Function 

This is the same as the syntax used for declaring a subroutine, except that a function includes a return type and ends with End Function.

The inheritance_mode can be one of the values Overloads, Overrides, Overridable, NotOverridable, MustOverride, Shadows, or Shared. These values determine how a subroutine declared within a class inherits from the parent class or how it allows inheritance in derived classes.

The accessibility clause can take one of the following values: Public, Protected, Friend, Protected Friend, or Private. These values determine which pieces of code can invoke the subroutine.

A function assigns its return value either by setting its name equal to the value or by using the Return statement. Using the Return statement may allow the compiler to optimize the code more, so it is generally preferred.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

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