Option Explicit
#If VBA7 Then
Private Declare PtrSafe Sub MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" _
(ByRef Destination As Any, ByRef Source As Any, ByVal Length As LongPtr)
#Else
Private Declare Sub MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" _
(ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
#End If
Sub Test()
Const Src As Long = 1234
Dim Dst1 As Long, Dst2 As Long, Dst3 As Long
MoveMemory VarPtr(Dst1), Src, 4
MoveMemory Dst2, Src, 4
MoveMemory ByVal VarPtr(Dst3), Src, 4 ' (absurde, juste pour montrer que c'est rigoureusement équivalent)
MsgBox "Dst1 = " & Dst1 & vbLf & "Dst2 = " & Dst2 & vbLf & "Dst3 = " & Dst3
End Sub