This has me baffled:
1. Any idea why L1 and L2 are not the same even though p1 and VarPtr(v1(0)) are the same number?Code:Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, _ Source As Any, ByVal bytes As Long) Sub VarPtrTest() Dim L1 As Long, L2 As Long, p1 As Long, A(1) As Long, v1 As Variant v1 = A 'assign array of long to the variant p1 = VarPtr(v1(0)) CopyMemory L1, ByVal p1, 4 'get 1st 4 bytes CopyMemory L2, ByVal VarPtr(v1(0)), 4 'get 1st 4 bytes Debug.Print p1; VarPtr(v1(0)); L1; L2 '1308228 1308228 0 16387 End Sub
2. Any idea what varPtr(v1(0)) really points to?





Reply With Quote