Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
只是一个关于 VBA 数组的快速问题......
如果我使用该ReDim Preserve语句并通过减小 Upper 索引号来调整 Array 的大小,会发生什么情况。如果myArray(5) ="Shmoo"我这样做怎么办:
ReDim Preserve
myArray(5) ="Shmoo"
ReDim Preserve myArray(2)
是否可以这样做,因为Preserve不能丢失与数组中每个索引号相关联的数据,并且数组中的索引号 5 具有字符串值“Smoo”?
Preserve
中myArray(3)的数据将丢失。只保留符合语句指定的新大小的数据。myArray(4)myArray(5)PreserveReDim
myArray(3)
myArray(4)
myArray(5)
ReDim
从 Excel VBA 帮助文件:
If you make an array smaller than it was, data in the eliminated elements will be lost.