varptr(MyVar)
returns a pointer to the variable MyVar
you can't access the memory directly but you can copy it to another variable
put this at the top of your code
Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
you have to use the Byval keyword to do the pointers
Code:
'a long variable
Dim lngMyLong As Long
' an array of bytes
Dim bytBytes(1 to 4) As Byte
'and some pointers
Dim ptrLong As Long
Dim ptrBytes As Long
ptrBytes = VarPtr(bytBytes(1))
ptrLong = VarPtr(lngMyLong)
'copy the bytes to the memory address at ptrLong
CopyMemory ByVal ptrLong, bytBytes(1), 4
'copy the memory at ptrBytes to the Long
CopyMemory lngMyLong, ByVal ptyBytes, 4
'copy the bytes to the long
CopyMemory lngMyLong, bytBytes(1), 4
'copy the memory at ptrBytes to the memory as ptrLong
CopyMemory ByVal ptrLong, ByVal ptyBytes, 4
all the copymemory lines do the same thing, when calling an API you can insert the ByVal argument infront of any argument (unless it's declared ByVal origianaly) this means that you are passing a pointer to a variable into the API instead of the variable itself
hope this helps