Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Intermediate
May 5, 1998

Declare Your Objects Properly

Never declare a variable as a "New" of type "object," but always rather just as of type "object." If you do so you will always increment the reference count of the object, even though you do not use it. Also, always remember to set your objects to nothing when finished. The wrong way is:
 
Private Sub Foo()
    Dim oCust as New clsCust

    'do stuff with oCust

End Sub
The right way is:
 
Private Sub Foo()
    Dim oCust as clsCust

    Set oCust = New clsCust
    'do stuff with oCust
    Set oCust = Nothing

End Sub
Joe Karbowski
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date