Solved

Accessing a Collection within a Class

Posted on 2001-08-16
4
158 Views
Last Modified: 2010-05-02
I have created two classes, one called Order and the other called LineItem. The Order class has a Collection in it of type LineItem. I am writing a method in my Order class to populate the Order object and the lineitem collection based on the order info in a database. However, I do not know how to access the lineitems from within this method. I have tried using the lineitem.add but I get an error. It would seem pointless to do a seperate Lineitem method to populate that, but it seems to be the only option unless I can figure out how to do it within the method of my Order object/class.

Any help would be appreciated!

Thanks.
0
Comment
Question by:kriskramer
4 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 100 total points
Comment Utility
declare the method as public
0
 
LVL 2

Expert Comment

by:BozzoCage
Comment Utility
If I properly undersood:

class LineItem
  private p_linedata as string
  public sub SetData(l as string)
     p_linedata = l
  end sub

class Orders
  private p_item as Collection
  public sub class_initialize
    set p_item=new Collection
  end sub
  public sub Populate
    dim l as new LineItem
    l.SetData (rst("name"))
    p_item.Add l
  end sub
  public function GetLineData(lineNo as long)
    GetLineData = p_item(lineNo)
  end function
 
------

Read code and ask if something is unclear.

Regards,
  BozzoCage  
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Hi kriskramer,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept bobbit31's comment(s) as an answer.

kriskramer, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
Comment Utility
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now