borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (Card Swipe KeyBoards) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Class Modules and Arrays
Poster Message
tekito
Level: Trainee

Registered: 25-06-2008
Posts: 2

icon Class Modules and Arrays

I am new to class modules and am having some difficulty.  Here is a description of the problem.

First off, I created a simple class, which was basically an array with some typical properties (like Sum, Max).  So, if I am using an instance A of the class and changing an element of the array, with my conventions it would look like A.Elt(i) = 6.

Next off, I want to create another class, which has these arrays as properties.  As expected, I can do this by declaring the first class as public variables in the class module. (So now, for an instance B of this class, editing the elements would look like B.A.Elt(i) = 6).  However, this class is going use A LOT of these arrays, and in fact they need to be in an array, for indexing purposes and simplicity of programming.  However, VB6 will not let you declare public arrays in a class module.  I am aware that I could declare an array as a private variable, but then I see no way to reference or directly edit the first class and its elements from "the outside".  In other words I cannot think of a way for B.A.Elt(i) = 6 to work if class A is not declared as a public variable in class B.

Very confused, any help would be appreciated.  Let me know if clarification is needed.

25-06-2008 at 09:39 PM
View Profile Send Email to User Show All Posts | Quote Reply
tekito
Level: Trainee

Registered: 25-06-2008
Posts: 2
icon Re: Class Modules and Arrays

I think I gave some unnecessary details of my problem.  Basically, I need a class that contains an array of objects.  In other words, how do you make a structured tier of arrays of objects (so that you could write A.B(j).C(k).Property = "blah")?  Defining public arrays as properties is prohibited.  If I define these arrays of objects as private, then I don't know how to expose them and their properties to the outside. The "Get" and "Let" procedures don't seem to make this possible.

I know that collections are allowed, but a few reasons I would prefer arrays.  This seems a basic problem so I would think it has a solution.

26-06-2008 at 03:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
stickleprojects
Level: Moderator


Registered: 09-09-2002
Posts: 1037
icon Re: Class Modules and Arrays

Hi
You should use collections for classes, as the mechanism for exposing arrays in com is horrid and completed.

Look athte class wizard, as this creates the colleciton object for you.

Can you clarify why you don't want collections?
ie.
.Add
.count
.Remove
are not in arrays


____________________________
Build it better, faster, quicker, easier.. then fix it (non-offical MS mission statement)

12-07-2008 at 03:15 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Class Modules and Arrays
Next Topic (Card Swipe KeyBoards) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Il portale per lui e lei | Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder