View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
[email protected][_2_] gimme_this_gimme_that@yahoo.com[_2_] is offline
external usenet poster
 
Posts: 236
Default VBA memory allocation

On Jun 25, 1:44 pm, vivmaha wrote:
I think you are right. I wrongly assumed that VBA was like JAVA and had a
'garbage collector' etc.

However, I dont know how to fix the problem. I'm getting an error when the
"collect.item(1)=nothing" line is called.

Here is the code:


Public Sub run()

Dim C As Collection
Set C = New Collection

Dim mc As Class1
Set mc = New Class1

C.Add mc

''''' Not required Set C.Item(1) = Nothing '<- Error thrown
here
mc = Nothing ' This is all you need
set C = Nothing

End Sub