2016-09-08 9 views
2

私はVBAの初心者です。 Word(.dotm)でテンプレートを作成しました。私は30 Stringオブジェクトを使用しています。私はVBAがそれを処分するかどうか、あるいはそれを手動で処分する必要があるのか​​どうかわかりません。VBAは文字列と配列のガベージコレクションを提供しますか?

誰でも私にお勧めしますので、今後のメモリの問題はありませんか?

+3

[this](http://stackoverflow.com/questions/19038350/when-should-an-excel-vba-variable-be-killed-or-set-to-nothing)answer。 – dee

答えて

3

処分する必要はありません。文字列変数が有効範​​囲外になるとすぐに、メモリが回復されます。

'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 
関連する問題