If I have a function that returns an object reference, such as this...
Sub GetRef()
MsgBox ObjRef.Name
End Sub
Function ObjRef() as Object
Set ObjRef = MyObj
End Function
What happens to that allocated memory space when the calling routine terminates? Is it automatically destroyed? Is it better to do something like this?
Sub GetRef()
Dim OR as Object
Set OR = ObjRef()
MsgBox OR.Name
Set OR = Nothing
End Sub
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.