Class objects and Memory

  • Thread starter Thread starter Jarryd
  • Start date Start date
J

Jarryd

Hi,

I have heard that is a good idea to set recordsets = nothing. Is there a
way to do the same for class objects. or is there no point?

TIA,

Jarryd
 
Then why do I get the following error message:

"Compile error:

Object required"
The objects I am setting to Nothing have all been initialised, and are
either Double or String. So what could be the problem?

TIA,

Jarryd
 
Could you post a sample of the code that is failing? I suspect that you are
trying to set a variable to nothing that is not pointing to an object.

Usually you will see the word SET when you are working with an object

SET MyRecordsSetVariable = ...
 
Jarryd wrote in message said:
Then why do I get the following error message:

"Compile error:

Object required"
The objects I am setting to Nothing have all been initialised, and are either
Double or String. So what could be the problem?

TIA,

Jarryd

In VB, that's data types (Date, String, Double, Integer...), and you
don't release variables declared as such.

Objects are instantiated using the Set statement

dim myobject as myclass
Set myobject = new myclass
' do something with the object
set myobject = nothing

- also, if the object is opened (like recordsets, connections ...),
one might close them first

And only those can be released - and many developers recommends to do
so.
 
Hi guys,

Put this one down to my own ingorance of basic terminology and programming
concepts. I had infact only declared variables of a certain datatype. E.g.:

Dim test as String
test = Form1_controlbox1

So if there is no need to release those then I'll just leave them as is.

TFYH,

Jarryd

"RoyVidar" <roy_vidar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top