-
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.
TIA,
Mill
-
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
--
Colin McGuigan
-
Re: Class Initialize
Andy,
>In VB, can you over-ride the default initialize procedure?
Not until VB7.
Until then, you have two options. First, you can add Init methods to
your classes:
Set x = New Cube
Call x.Init(3)
Or you can create accessor functions that do the same work for you.
Ciao, Craig
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks