Hi Eric,
There's a lot that doesn't make sense. I started trying to second guess the
objectives but gave up, can't see how it ever worked at all yet alone make
Excel crash. You have typed code direct into the post rather than copying
the original, I suspect typos and/or omissions occurred while doing that.
Regards,
Peter T
wrote in message
ps.com...
I have to admit that I still not get how things work with references in
VB.
I have an object that looks like:
---- myObjectClass -----
private dim myColl as collection
private sub class_initialize()
set myColl = new collection
end sub
private sub class_terminate()
set myColl = nothing
end sib
private function add(v as variant)
myColl.add(v)
end function
public function initilize(a as string)
dim b as variant
dim i as integer
b = split(a,";")
for i = lbound(b) to ubound(b)
myColl.add b(i)
next
end function
----------------------------------
Now I want to write an object function that returns a reference to a
new myObjectClass, with just some of the elements in myColl. I wrote it
like this
---- myObjectClass -----
public function return_match(a as string) as myObjectClass
dim newObject as new myObjectClass
for each c in myColl
if a c then newObject.add(c)
next
return_match = newObject
end function
----------------------------------
I now use it like this:
dim full_list as myObjectClass
dim sub_list as myObjectClass
set full_list as new myObjectClass
full_list.initialize("apples;bananas;citrus;dates; figs")
set sub_list = full_list.return_match("c")
-----------------------------------
I think it works, but I have crashes now and then. Does this have
memory problems, since I allocate a new object in return_match but
never free it? If so, how would I go ahead to return the object as a
reference?
Best Regards
Eric