Solved

Accessing a Collection within a Class

Posted on 2001-08-16
4
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 18

Accepted Solution

by:
bobbit31 earned 100 total points
ID: 6394348
declare the method as public
0
 
LVL 2

Expert Comment

by:BozzoCage
ID: 6394803
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
ID: 7202339
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
ID: 7215951
Per recommendation, force-accepted.

Netminder
CS Moderator
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month7 days, 9 hours left to enroll

632 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