gpt4 book ai didi

vba - VBA 是否为 String 和 Array 提供垃圾回收?

转载 作者:行者123 更新时间:2023-12-04 21:25:44 25 4
gpt4 key购买 nike

我是 VBA 初学者。我在 Word (.dotm) 中创建了一个模板。我使用了 30 个 String 对象。我不知道是 VBA 处理它还是我需要手动处理它。

谁能给我建议,这样我以后就不会有内存问题了?

最佳答案

无需处理。一旦字符串变量超出范围,内存就会被回收。

'Globally scoped g will be retained until the project is reset with `End`
Public g as string

Sub foo()
Dim s as string
s = "foo"

g = "bar"

's is destroyed on exiting the sub
End Sub

Sub bar()
' Reset the project will reclaim all variables including Globals
End
End Sub

关于vba - VBA 是否为 String 和 Array 提供垃圾回收?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39383546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com