The Any keyword is used as a placeholder for a type or value in various ways.

Dim identifier As Any Pointer|Ptr
Declare Sub|Function identifier ( Byref identifier As Any [ , ... ] )
Dim identifier(Any [, Any...]) As DataType
[ Declare ] { Sub | Function } proc_name ( param(Any [, Any...]) As DataType )
Dim identifier As DataType = Any
New DataType ( Any )
New(address) DataType [count] { Any }
Instr|InstrRev ( identifier, Any substring )
Procptr ( identifier, [Virtual] Any )

Declare Sub echo(ByVal x As Any Ptr) '' echo will accept any pointer type

Dim As Integer a(0 To 9) = Any '' this variable is not initialized
Dim As Double  d(0 To 4)

Dim p As Any Ptr

Dim pa As Integer Ptr = @a(0)
Print "Not initialized ";
echo pa       '' pass to echo a pointer to integer

Dim pd As Double Ptr = @d(0)
Print "Initialized ";
echo pd       '' pass to echo a pointer to double

p = pa     '' assign to p a pointer to integer
p = pd     '' assign to p a pointer to double      


Sub echo (ByVal x As Any Ptr)
    Dim As Integer i
    For i = 0 To 39
        'echo interprets the data in the pointer as bytes
        Print Cast(UByte Ptr, x)[i] & " ";
End Sub

'Example of ANY disabling the variable type checking
Declare Sub echo (ByRef a As Any) '' ANY disables the checking for the type of data passed to the function

Dim x As Single
x = -15
echo x                  '' Passing a single to a function that expects an integer. The compiler does not complain!!            

Sub echo (ByRef a As Integer)
  Print Hex(a)        
End Sub

Dim a(Any) As Integer ' 1-dimensional dynamic array
Dim b(Any, Any) As Integer ' 2-dimensional dynamic array
Dim c(Any, Any, Any) As Integer ' 3-dimensional dynamic array
' etc.

' Further Redims or array accesses must have a matching amount of dimensions
ReDim a(0 To 1)
ReDim b(1 To 10, 2 To 5)
ReDim c(0 To 9, 0 To 5, 0 To 1)

Dialect Differences:
Differences from QB:
See also:
Back to Procedures
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode