Hi,
the code below uses the CopyMemory API to copy the address of the variable X to a variable Y.
after carrying out the copying of memory, the variable Y should contain the value in X.
Then , if I change the value in X, the variable Y SHOULD now contain the new X value BUT that's not the case as the following test code shows :
VB Code:
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (pDst As Long, pSrc As Long, ByVal ByteLen As Long) Sub test() Dim x As Long Dim y As Long x = 123 CopyMemory y, x, LenB(x) MsgBox y ' this show 123 as expected x = 888 MsgBox y ' this should show 888 but shows 123 instead !!!! End Sub
Why is Y - in the second MsgBox - still showing (123) instead of showing the new value in X ie(888)?!
Am I missing something ?![]()
Any help much appreciated .




Reply With Quote