Solved

Accessing a Collection within a Class

Posted on 2001-08-16
4
162 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
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBS file using code from 2nd file (txt or vbs) 4 42
Adding to a VBA? 6 76
Advice in Xamarin 21 96
Create Files based on Cell Values in a Range in Excel 12 43
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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