Microsoft Office Tutorials and References
In Depth Information
The SUM function adds everything in the statement that calls it; if it can’t make sense of its
input, such as when it tries to add a non-numerical value, it will return an error message and
display an error code. If a Function procedure has no arguments, its Function statement must
include an empty set of parentheses.
Private | Public ] [ Static ] Function name [( arglist )] [As type] [
[name = expression]
Exit Function ] [
[name = expression]
End Function
Table 5-2 describes the elements of a Function procedure, many of which will be familiar
from the description of a Sub procedure.
Table 5-2. Elements of a Function Procedure
An optional element that indicates the Function procedure is
accessible to all other procedures in all modules. If used in a module
that contains an Option Private statement, the procedure is not
available outside the project.
An optional element that indicates the Function procedure is
accessible only to other procedures in the module where it is
An optional element that indicates the Function procedure’s local
variables are preserved between calls. The Static attribute doesn’t
affect variables that are declared outside the Function procedure,
even if they are used in the procedure.
A required element that indicates the name of the Function (for
example, Function InterestDue ). The name does need to follow the
standard variable naming conventions.
An optional list of variables representing arguments that are passed
to the Function procedure when it is called. Multiple variables are
separated by commas.
An optional statement that specifies the data type of the result
returned by the Function procedure. For example, a function returning
an integer value would have As Integer in this space.
An optional group of statements to be executed within the Function
Search JabSto ::

Custom Search