Declares or defines a member procedure returning a value.
Syntax
Parameters
typename
fieldname
name of the procedure
external_name
name of field as seen when externally linked
parameters
the parameters to be passed to the procedure
calling convention specifier
Description
Function members are accessed with
Operator . (Member Access) or
Operator -> (Pointer To Member Access) to call a member procedure that returns a value. The procedure may optionally accept parameters either
ByVal or
ByRef.
typename be overloaded without explicit use of the
Overload keyword.
typename is the name of the type for which the
Function method is declared and defined. Name resolution for
typename follows the same rules as procedures when used in a
Namespace.
A hidden
This parameter having the same type as
typename is passed to non-static member procedures.
This is used to access the fields of the
Type,
Class, or
Union.
A
Static (Member) may be declared using the
Static specifier. A
Const (Member) may be declared using the
Const specifier.
Example
#include "vbcompat.bi"
Type Date
value As Double
Declare Static Function Today() As Date
Declare Function Year() As Integer
Declare Function Month() As Integer
Declare Function Day() As Integer
End Type
Function Date.Today() As Date
Return Type(Now())
End Function
Function Date.Year() As Integer
Return ..Year(value)
End Function
Function Date.Month() As Integer
Return ..Month(value)
End Function
Function Date.Day() As Integer
Return ..Day(value)
End Function
Dim d As Date = Date.Today
Print "Year = "; d.Year
Print "Month = "; d.Month
Print "Day = "; d.Day
Dialect Differences
See also