LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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.


 
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 03:30 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"