Declare Procedure Method

The Declare Procedure method declares a procedure in a module or in a dynamic link library (DLL). The value it returns depends on one of the following formats that you use:

  • Format A. It does not return a value.

  • Format B. A value of the funcType type. You can use this value in an expression.

For more information about the format and arguments that you can use with this method, see Declaring a Procedure.

Format A

Declare Sub name [(argument [As type])]
Declare Function name [(argument [As type])] [As funcType]

The following table describes the arguments that you can use with this method.

Argument Description

name

The name of the subroutine or function that this method declares.

argument

The argument that this method passes. A comma separates each argument.

type

The data type of the arguments.

funcType

The data type of the return value.

Example

The following example declares a function that the main subroutine subsequently calls. This function only sets the return value to 1:

(general) (declarations)
Option Explicit
Declare Function SVB_exfunction()
Function SVB_exfunction()
   SVB_exfunction = 1
End Function
Sub Button_Click
   Dim y as Integer
   Call SVB_exfunction
   y = SVB_exfunction
End Sub

For other examples of functions, see Create Function Method and Go To Statement.

Related Topics