AddressOf

Most of the time you will not need to obtain any low level information about your variables.
However there are a few Windows API functions that require the memory address of a variable.

link - learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/addressof-operator 

Declare Function EnumFontFamilies Lib "gdi32" Alias _ 
     "EnumFontFamiliesA" _
     (ByVal hDC As Long, ByVal lpszFamily As String, _
     ByVal lpEnumFontFamProc As Long, LParam As Any) As Long

Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long

Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, _
     ByVal hDC As Long) As Long

Sub FillListWithFonts(LB As ListBox)
   Dim hDC As Long
   LB.Clear
   hDC = GetDC(LB.hWnd)
   EnumFontFamilies hDC, vbNullString, AddressOf EnumFontFamProc, LB
   ReleaseDC LB.hWnd, hDC
End Sub

When you want to use API functions the following functions will prove useful:
VarPtr - returns the address of a variable
VarPtrArray - returns the address of an array
VarPtrStringArray - returns the address of an array string
StrPtr - returns the address of the UNICODE string buffer
ObjPtr - returns the pointer to the interface referenced by an object variable


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrev