Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Problem using an object inside another object..

Hello !

In a form module, I create an instance of a class object and I
initialize this object.

Set obj01 = New clsObj01

Later in the same procedure I create some instances of another class,
Set obj0201 = New clsObj02
Set obj0202 = New clsObj02
Set obj0203 = New clsObj02

All these objects are created in the UserForm_Initialise procedure and
destroyed in the UserForm_Terminate proc.

They are also defined as global at the form module level
Private obj01 AS clsObj01
Private obj0201 AS clsObj02
Private obj0202 AS clsObj02
Private obj0203 AS clsObj02


Always in the UserForm_Initialize procedure, I set one of this second
class properties to the first object in all instances :

Set obj0201.obj = obj01
Set obj0202.obj = obj01
Set obj0203.obj = obj01


This second class has the correct Property Set procedure :

Public Property Set ExtObject (obj AS clsObj01)
Set mobj = obj
End Property

of course, mobj is defined global at module level :
Private mobj AS clsObj01


Tracing the code in the property Set procedure, I can query the
properties of mobj and the correct values are returned.


In the clsObj02 module, there's another method I call later that uses
one of the properties of mobj

Public Sub ...

If mobj.Complete = True Then ...

I get an error 91 on that line (undefined object variable), and the
local variables window shows that mobj is nothing.

Since obj01 still exists (the form is still displayed and it's
Terminate procedure never executed at that point), I don't understand
why this happens..

Any idea ?
Thanks

NB: I also tried to use "Private mobj AS *New* clsObj01" in clsObj02,
but it doesn't make any difference, and IMHO it is not required because
it is not a new object, but a reference to an existing object.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Problem using an object inside other objects (additional info)..

I have additional info following some test I made :

I added a property "Name" to clsObj01, and defined it in the formModule

Set obj01 = New clsObj01
obj01.Name = "Form Module Instance"

Later, just after I passed the object to the other class instances

Set obj0201.obj = obj01
Set obj0202.obj = obj01
Set obj0203.obj = obj01


I put this code :

Debug.Print obj0201.obj.Name (result: "Form Module Instance")
Debug.Print obj0202.obj.Name (result: "")
Debug.Print obj0203.obj.Name (result: "")

Now I can see why I get the error 91 when using the object in instances
02 and 03 of clsObj02, but I still no not understand why the actual
obj01 reference is not kept inside obj0202 and obj0203..

Still looking for ideas or explanation..


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Solved:: Problem using an object inside other objects

I just found the problem : it is sitting on my chair !

Too much cut & paste, not enough coffee.. Well, it proves sometimes
you have to take a little break to get a clearer mind - and see the
obvious.

Apologies to all..
MS


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy/Paste charts as object inside excel Khoshravan Charts and Charting in Excel 1 September 17th 07 02:54 PM
Object Is Object evaluation problem mickey Excel Programming 4 November 20th 06 05:40 PM
While rotating object, how to rotate the text inside - in excel A.Mohandas Excel Discussion (Misc queries) 1 April 23rd 06 12:03 AM
Implement object persistence inside Excel Tom Chau Excel Discussion (Misc queries) 2 April 7th 06 01:48 AM
Assigning array to range inside Excel Object Jon Peltier Excel Programming 0 April 1st 04 11:14 PM


All times are GMT +1. The time now is 01:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"