LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Return reference from object function

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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
function to find value and return cell reference rcc Excel Discussion (Misc queries) 6 June 27th 12 02:55 AM
how do I create a cell reference from ADDRESS function return? Coachdenny Excel Worksheet Functions 3 December 2nd 08 04:22 AM
return the column reference number of a function result Mahendhra Excel Discussion (Misc queries) 2 May 16th 05 12:46 PM
Function return by reference R Avery Excel Programming 3 August 10th 04 10:43 PM
Function unable to return Collection object Adrian[_7_] Excel Programming 1 July 12th 04 06:22 PM


All times are GMT +1. The time now is 11:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"