Search notes:

VBA operator: addressOf

The addressOf operator evaluates to a long (at least on 32 Bit Windows versions) which usually are used for used for Win API callbacks (such as needed for EnumWindows or EnumChildWindows).
option explicit

sub XX()

  dim cbAddr as long
   
  '
  '  addressOf is an operator, not a function.
  '  Therefore, the following is not possible,
  '  it causes a "Compile error, Syntax error"
  '
  '   cbAddr = addressOf callBackSub
  '
  '  However, cbAddr can be assigned the address of
  '  a call-back function or sub with the following
  '  construct:
  
  cbAddr = getAddressOfCallback(addressOf callBackSub)

end sub


function getAddressOfCallback(addr as long) as long
         getAddressOfCallback=addr
end function


sub callBackSub()

    msgBox "xyz"

end sub
Github repository about-VBA, path: /language/operators/addressOf.bas

Directly using value of the result of addressOf

Because addressOf is an operator, it cannot be directly used to use the value it evaluates to directly, the following would not work:
dim addr as longPtr
addr = addressOf(…)
However, with vba.int(…), it becomes possible:
dim addr as longPtr
addr = vba.int(addressOf(…))

See also

Calling VBA functions from a DLL.
VBA language

Index