What If a Variable Doesn't Refer to Anything?

Started by sukishan, Sep 04, 2009, 10:29 PM

previous topic - next topic
Go Down


What If a Variable Doesn't Refer to Anything?
How can you tell if an object variable doesn't refer to anything? When working with dynamic data structures, you'll find it useful to be able to discern whether a reference has yet been instantiated. Pascal uses Nil, C uses Null, and VBA uses Nothing to represent the condition in which an object variable doesn't currently refer to a real object.

If you have an object variable and you've not yet assigned it to point to an object, its value is Nothing. You can test for this state using code like this:

If objItem Is Nothing Then
    ' You know that objItem isn't currently referring to anything
End If If you want to release the memory used by an object in memory, you must sever all connections to that object. As long as some variable refers to an object, VBA won't be able to release the memory used by that object. (Think of it as a hot-air balloon, tied down with a number of ropes; until someone releases the last rope, that balloon isn't going anywhere.) To release the connection, set the object variable to Nothing:

Set objItem = NothingOnce you've released all references to an object, VBA can dispose of the object and free up the memory it was using.
A good beginning makes a good ending


As per my knowledge I want to include from all of above if a user variable is assigned a nonbinary (character) string value, it has the same character set and collation as the string.

Go Up

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Please leave this box empty:

Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

shortcuts: alt+s submit/post or alt+p preview
IT Acumens Web Designing Chennai | GinGly :: Build your Personal Website | CineBuzz :: Cinema News | My Kids Diary :: Kids Memories Writing :: Book Website @ 349 Rs monthly
Copyright 2005 - 2020 :: IT Acumens :: All Rights Reserved. :: Sitemap
ITAcumens Discussion Forum with 2 lakhs post running for 15 years - Powered by IT Acumens Dedicated Server