Skip to Content
VB & VBA in a Nutshell: The Language
book

VB & VBA in a Nutshell: The Language

by Paul Lomax
October 1998
Intermediate to advanced
656 pages
16h 10m
English
O'Reilly Media, Inc.
Content preview from VB & VBA in a Nutshell: The Language
Function Statement

Named Arguments

No

Syntax

[Public | Private | Friend] [Static] Function name _
          [(arglist)] [As type][()] 
   [statements]
   [name = expression]
   [Exit Function] 
   [statements]
   [name = expression]
End Function

Public

Use: Optional

Type: Keyword

Gives the function scope through all procedures in all modules in the project. If used within a createable class module, the function is also accessible from outside the project. Public, Private, and Friend are mutually exclusive.

Private

Use: Optional

Type: Keyword

Restricts the scope of the function to those procedures within the same module. Public, Private, and Friend are mutually exclusive.

Friend

Use: Optional

Type: Keyword

Only valid within a class module; gives the function scope to all modules within a project, but not to modules outside the project. Public, Private, and Friend are mutually exclusive.

Static

Use: Optional

Type: Keyword

Preserves the value of variables declared inside the function between calls to the function.

name

Use: Required

The name of the function.

arglist

Use: Optional

A comma-delimited list of variables to be passed to the function as arguments from the calling procedure.

type

Use: Optional

The return data type of the function.

statements

Use: Optional

Program code to be executed within the function.

expression

Use: Optional

The value to return from the function to the calling procedure.

arglist uses the following syntax and parts:

[Optional] [ByVal | ByRef] [ParamArray] varname[( )] [As type
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Absolute Beginner's Guide to VBA

Absolute Beginner's Guide to VBA

Paul McFedries
Visual Basic 2015 Unleashed

Visual Basic 2015 Unleashed

Alessandro Del Sole

Publisher Resources

ISBN: 1565923588Catalog PageErrata