Aaron's response is nicely more succinct than mine and indicates that you
shouldn't have to write a Class_Initialize function in this case, but
I think the "set init = me" line is required in order for this
approach to work, and that init would therefore need to be a function
rather than a sub
On Mon, Apr 30, 2012 at 01:40:17PM -0400, Aaron Smith wrote:
Class_Initialize doesn't take parameters. You can add a custom
Init/Start routine to your class, which accepts the parameters you want
to use. Then you can instantiate the class, and call the custom routine
in one line, like this:
Class MyClass
Private a, b, c
Public Sub Init(x, y, z)
a = x
b = y
c = z
End Sub
End Class
Set myObject = (New MyClass).Init(1, 2, 3)
The wiki article "[1]Using Class Based Event Handlers" demonstrates
this practice.
Aaron
On 4/30/2012 1:20 PM, David Helkenn wrote:
Hello,
Does VB Script support a way to parameterize a class? In some
languages, it is possible to define a 'virtual' or 'generic' class,
such that when it is instantiated, the developer supplies the
required parameters. For example, a virtual stack may be one number
deep in one instance and another depth in a second instance. Or, the
contents of the stack may be trucks in one, cows in a second, or
temperatures in a third. In other words, it might be possible to
define stacks of differing depths, differing objects, or both. For
example, supply the required parameters and one could get a stack of
up to 8 cows, etc.
I'm not finding any way to have half a dozen 'stacks' for my data
objects -- one stack of four, another of 13, and the rest with 22.
Thanks for any help with this one!
Dave
--
Aaron Smith
Web Development * App Development * Product Support Specialist
GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825
260-489-3671 * gwmicro.com
To insure that you receive proper support, please include all past
correspondence (where applicable), and any relevant information
pertinent to your situation when submitting a problem report to the GW
Micro Technical Support Team.
References
1.
http://www.gwmicro.com/mediawiki/index.php/Using_Class_Based_Event_Handlers
--
Doug Lee, Senior Accessibility Programmer
SSB BART Group - Accessibility-on-Demand
mailto:[email protected] http://www.ssbbartgroup.com
"While they were saying among themselves it cannot be done,
it was done." --Helen Keller