|
-
Oct 10th, 2002, 01:21 PM
#1
Thread Starter
Registered User
How are objects destroyed in VB6?
Posed this one also in COM\ActiveX forum, sorry about this...
Anyone ideas about this one ?
I have a main app and two classes. The first class gets an ADO recordset from an Access2000 DB. The second class generates
a csv file from an ADO recordset.
So my main app asks class1 for a recordset and feeds it into
class2 which is working fine.
I am just wondering if the recordset object is being properly destroyed because it first gets instantiated in class 1 and then
passed by reference all over the project (sometimes using "local" references to the same recordset).
I saw in VB6 help that if you have multiple references to 1 object, the object gets released if you set the last ref. to nothing.
OK; but what about passing references ??
Does anyone have a clear explanation for this ?
THANKS,
Jukke
-
Oct 10th, 2002, 01:23 PM
#2
PowerPoster
If you are passing it ByRef, setting it to nothing would destroy the object for teh whole project, unless you instantiate it again.
-
Oct 10th, 2002, 01:34 PM
#3
Thread Starter
Registered User
So for example :
In Class1 :
Public function GetData() as ADO.RecordSet
...
GetData = ...
End Function
In Main :
Public sub Main()
Class2.Dosomething(Class1.GetData)
End Sub
In Class 2 :
Public sub Dosomething (rst as ADO.RecordSet)
...
Set rst = nothing
End sub
So this means that the rst object gets destroyed in Class 2 upon set to nothing ?
-
Oct 10th, 2002, 01:37 PM
#4
PowerPoster
I am not sure, but is the function return by value ByRef or ByVal. If its ByVal, it is not getting destroyed, but if its ByRef, it is getting destroyed.
-
Oct 10th, 2002, 01:46 PM
#5
Originally posted by amitabh
I am not sure, but is the function return by value ByRef or ByVal. If its ByVal, it is not getting destroyed, but if its ByRef, it is getting destroyed.
well by default it is byref if you don't specify... so by your example and from what amitabh said about destroying objects... these objects would be destroyed...
but i personally like to use a hammer to destroy mine
-
Oct 10th, 2002, 01:49 PM
#6
PowerPoster
I am not so sure. The functions return value can be ByRef beacuse it is always assigned to another variable. Okay I will just test it out.
-
Oct 10th, 2002, 01:53 PM
#7
PowerPoster
Sorry, it is ByRef. I just got confused.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|