Using Excel??™s VBE, you can create your own objects that contain custom properties and
methods that you define. You do this by creating classes in class modules. Here??™s the definition
of an object (from Microsoft??™s ASP.NET forums at http://forums.asp.net/p/1117506/
1933142.aspx):
Class: The formal definition of an object. The class acts as the template from which an
instance of an object is created at run time. The class defines the properties of the object
and the methods used to control the object??™s behaviour.
In a standard code module, public functions and subroutines you create can be called
from anywhere in your code simply by referencing the procedure. Code in a class module
must be explicitly instantiated, as in the preceding ADO Recordset example. Until an object
is instantiated in this manner, its methods and properties are not available to your code.
Another difference is that standard code modules can contain any number of related or
unrelated procedures (although best practices dictate that code in a given module should be
related to specific functionality, reality tells us that this is not always the case, and there is no
enforcement of this practice within a standard code module). Code in a class module by definition
defines the methods, properties, and events for objects that you create from a class.
These methods, properties, and events are all directly related to the object, and their inner
workings do not need to be known to implement or use the object.
Pages:
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56