ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
CDChris Day28/02/2013

Hi,

After updating to SolidWorks 2013 and consequently VBA 7.1 some lines of code that were previously functional now result in errors. Most of them were related to keeping UserForms on top of other windows so are now obsolete, but the declaration below is critical for other functionality.

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)

Does anyone know a fix for this? I wasn't able to add a reference to kernel32.dll, I guess because 32-bit systems are no longer supported, but how do I use this RtlMoveMemory function? If it helps, its alias is used as below.

Public Function ArrayIsInitialized(arr) As Boolean

    Dim memVal As Long

    CopyMemory memVal, ByVal VarPtr(arr) + 8, ByVal 4       'get pointer to array

    CopyMemory memVal, ByVal memVal, ByVal 4                'see if it points to an address...

    ArrayIsInitialized = (memVal <> 0)                      '...if it does, array is intialized

End Function

Thanks.