SUB Pointer


Data type that stores a pointer to a SUB procedure

Syntax:
dim variable as Sub [CDecl|Pascal|StdCall] [( [parameter_list] )] [= initializer]

Parameters:
parameter_list: parameter[, parameter[, ...]]
parameter: [ByRef|ByVal] identifier [As type] [= default_value]
identifier: the name of the variable referenced in the subroutine
type: the type of variable
default_value: the value of the argument if none is specified in the call
intializer: address of a subroutine to set as the intial value

Description:
A Sub pointer is a procedure pointer that stores the memory location of compiled code. If no intializer is given the default initial value is zero (0).

The memory address for the Sub procedure can be assigned to the variable by taking the address of a subroutine with ProcPtr or Operator @ (Address of).

The procedure must match the same Sub declaration as the declared Sub pointer.

To call the subroutine assigned, use the variable name as if it were a normal declared Sub.

Examples:
    Sub Hello()
        Print "Hello"
    End Sub

    Sub Goodbye()
        Print "Goodbye"
    End Sub

    Dim x As Sub() = ProcPtr( Hello )

    x()

    x = @Goodbye  '' or procptr(Goodbye)

    x()


Differences from QB:
See also:
Back to Standard Data Types

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode