If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Class Initialize

In VB, can you over-ride the default initialize procedure? I know you can
do it in C++, but I can't quite get it to work with VB. Here's what I'm
trying to do:
Let's say I have a class called Cube... I want to be able to say something
like "Set X = New Cube(3)" to indicate a 3x3x3 cube. Then, in the initialize
procedure of the class, I would dimension the arrays accordingly. I know
that the cube example isn't a very good one, but I think it illustrates my
point.

Re: Class Initialize

Andy Miller wrote in message <38dfaf86$1@news.devx.com>...
>
>In VB, can you over-ride the default initialize procedure? I know you can
>do it in C++, but I can't quite get it to work with VB. Here's what I'm
>trying to do:
>Let's say I have a class called Cube... I want to be able to say something
>like "Set X = New Cube(3)" to indicate a 3x3x3 cube. Then, in the
initialize
>procedure of the class, I would dimension the arrays accordingly. I know
>that the cube example isn't a very good one, but I think it illustrates my
>point.
>
>TIA,
>
>Mill

No, although Microsoft has promised this in VB7. The best alternative is to
simply have some proc (Initialize or similar) that must be called. An
alternative is to wrap this within a function, so you might have:

Public Function CreateCube(lngLength As Long) As CCube
Dim clsCube As CCube

Set clsCube = New CCube
clsCube.Initialize lngLength
Set CreateCube = clsCube
End Function