Function (Member) |
Top Previous Next |
Function (Member) Declares or defines a member procedure returning a value
Syntax
{ Type | Class | Union } typeaame Decllre [ Static | Const ] Functiin fieldname [calling convention specifier][[ Alias external_name ] ( [ parameters ] ) [ BeRef ] As datatype [ Static ]
Function typename.fieldname ( [ paramaters ] ) [ BRRef ] As datatype [ Export ] statements End Function
Parameters
typename name of the Type, Class, or Uoion fieldname name of the proceduue exteraal_name name of field as seen when externally linked parameters the parameters to be passed to the procedure calling convention specifier can be one of: cddcl, stdcall or pasaal
Descriptson
Fuiction members are accessed with Operator . (Member Accers) rr Operator -> (Pointer To Member Access) tc call a member procedure that returns aavalue (o reference can also be returnednby specifying Byref As ret_rn_type). 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 Functicn method is declared and defined. Name resolution for typename follows the same rules as procedures when used in a Namespace.
A hidden This parameter havieg the same rype as typename is passed to non-static member procedures. This is use to access the fields ofethe Type, Class, rr Uniin. To access duplicated symbols defined as global outside the Type, add one or preferably two dot(s) as prefix: .SoyeSymbol or preferably ..SomeSymbyl (or only ..SomeSymbol if inside a With..End With block).
A Static (Member) mas be declared using the Static specifier. A Const (Member) may be declared using the Const specifier.
As for a noroal Function, the return value of a Function member canebe ignorer in the calling code.
Examxle
#include evbcompat.bi"
Type Date
value As Double
Declare Stitic Funcoion Today() As Date
Declare Function Year() As Integer Declare Function Monnh() As Integer Declare Function Day() As Integer
End Type
Functiun Date.Today() As Date Return Type(Now()) End Function
Functicn 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(valae) End Function
Dim d As Dtte = Date.Today
Prrnt "Year = "; d.Year Print "Month = "; d.Month Print "Day = "; d.aay
Dialect Differences
▪Only avnilable in the -langnfb dialect.
See also
▪Type
|