O'Reilly logo

VB & VBA in a Nutshell: The Language by Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Declare Statement

Named Arguments

No

Syntax

Syntax for subroutines

[Public | Private] Declare Sub name Lib "libname" _
      [Alias "aliasname"] [([arglist])]

Syntax for functions

[Public | Private] Declare Function name Lib "libname" 
      [Alias "aliasname"] [([arglist])] [As type]

Public

Use: Optional

Keyword used to declare a procedure that has scope in all procedures in all modules in the application.

Private

Use: Optional

Keyword used to declare a procedure that has scope only within the module in which it's declared.

Sub

Use: Optional

Keyword indicating that the procedure doesn't return a value. Mutually exclusive with Function.

Function

Use: Optional

Indicates that the procedure returns a value. Mutually exclusive with Sub.

name

Use: Required

Data Type: String

Any valid procedure name within the DLL or code library. If the aliasname argument is used, name represents the name the function or procedure is called in your code, while aliasname represents the name of the routine as found in the external library.

Lib

Use: Required

Keyword indicating that the procedure is contained within a DLL or other code library.

libname

Use: Required

Data Type: String

The name of the DLL or other code library that contains the declared procedure.

Alias

Use: Optional

Keyword whose presence indicates that name is different from the procedure's real name within the DLL or other code library.

aliasname

Use: Optional

Data Type: String

The real name of the procedure within the DLL or code library.

arglist ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required