I'm trying to understand the official Microsoft VBA documentation for the LSet statement, specifically this warning in the example section:
Due to the varying implementations of data structures among platforms, such a use of LSet can't be guaranteed to be portable.
Source: https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/lset-statement
Question: What specifically does "platforms" refer to in this context? My assumption is that "platforms" refers to either:
- Different operating system versions (Windows 7, Windows 10, Windows 11, etc.)
- Different CPU architectures (x86, x64, ARM, etc.)
- Or possibly both
What I've tried:
However, I cannot find any official Microsoft documentation that explicitly defines what "platforms" means in this VBA context.
- Searched through Microsoft's VBA documentation
- Asked AI assistants, but received unclear answers
- Looked for clarification in related MSDN articles
The context suggests it's related to data structure implementation differences that could affect the portability of using LSet to copy between different user-defined types, but I need confirmation of what specific platform differences are being referenced. Can anyone point me to official documentation or provide authoritative clarification on what "platforms" means in this VBA warning?
LSetdocs, they are really talking about the different environments where VBA can run. That covers things like the operating system (Windows or Mac), the specific Office host (Excel, Word, Access), and the version or bitness of VBA itself (32-bit, 64-bit, VBA 6, VBA 7). Each of these factors can influence how user-defined types (UDTs) are stored in memory, how fields are aligned, and whether padding is inserted. CONTD...LSetis not a safe way to copy one UDT into another if you want the code to work everywhere.LSetjust moves raw bytes around, ignoring type safety. If the memory layout differs between platforms, you can end up with corrupted values or misinterpreted data. For example, differences in pointer size, alignment rules, or string storage (Unicode vs ANSI) can cause code that runs fine on one system to break on another. That is why the warning exists.I would like to check difference of environments in several computers. So, I need some script to check it.If you type this in ChatGpt or CoPilot, it can spit out an entire set of script for you. I just tried it and it worked. I would recommend giving it a try and then if you do not understand anything in that script then, post the script here with your understanding and we can help you figure it out...Integerfollowed by aDoubleyou might get an 8-byte alignment on x64 i.e. 6-byte padding but that might look different on x32 e.g. 4-byte alignment (2-byte padding) - but you can just insert 3 dummyIntegersin between the two. In short, it depends on the use case.