Class modules 97 - Refering to array within a custom class module 
Author Message
 Class modules 97 - Refering to array within a custom class module

New within access97 is the ability to create custom class modules.  I am
trying to use this new functionality to creat a custom object that will
represent a report.  By referencing this object I will be able to see what
will need to be included in a report and other basic information such as
address and company name.

I have the problem that there is not all that much documentation on this
new functionality and therefor have hit many problems.  Here is one that
would be good if it was solved.

Within a class module I have defined  properties that are of type variant
and they conatain an array.  The following line can be used to refer to one
of the elements of the array where class1 is the class modules name and
array1 is a two dimensioned array.

temp = Class1.Array1(1,0)

This works.

If I define an object at the begining of the function and then assign it to
the class and then try to refer to it in the same way as follows

dim Object1 AS Object

set Object1 = Class1.Array1
Temp = Object1(1,0)

Does not work and returns "Object not a collection" error.  Should this
happen and if so what do I do about it.  Also can you suggest any new
documentation on this new functionality.

I hope you can help and if you can it would be appreciated.

Matthew van der Linden



Mon, 03 Jan 2000 03:00:00 GMT  
 Class modules 97 - Refering to array within a custom class module


says...

Quote:
> dim Object1 AS Object

> set Object1 = Class1.Array1
> Temp = Object1(1,0)

First of all, avoid using "Object" as a data type, at all costs.  It's
slow, and you get no "IntelliSense" help.

You can't make an Object point at a variant. You should be using

  Dim varItems as Variant
  varItems = Class1.Array1
  Temp = varItems(1, 0)

I've not done this, but it ought to work.

For a TON of example class modules, you might check out "VBA Developer's
Handbook" (Sybex, 1997). This book (which I co-wrote) is chock full of
examples using class modules. -- Ken



Mon, 03 Jan 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Accessing procedures of a class module from another class module

2. Refering to form by class module

3. Class Module Access 97

4. Access 97 Class Modules (Visio)

5. Circular Reference Between Modules when 2 Class Modules Listen to Each others Events

6. Class Module and Module

7. Class Modules & Modules

8. VB Modules/Class Modules

9. class module vs. module

10. modules and class modules

11. Returning the name of a module/class module

12. Modules or Class modules?

 

 
Powered by phpBB® Forum Software