Creating Object Models in VB

I'm coding in VB6 and I'm trying to create an Application object that in turn has two other objects. One is ActiveProject and the other is a collection called Projects. so this is my model:

Application
  |
  -----ActiveProject
  |
  -----Projects

I want it such that when a user creates a new project using the collection object, ActiveProject is created. I also want an item property in the Projects collection to share the same properties as ActiveProject (i.e ProjectName, ProjectID).

Any Ideas?
VBTechpapiAsked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Thats depends on how you are handling your projects.  If the user simply selects a project from a list then you just need to set m_iActiveProject to the index of the project selected.
0
 
Carl TawnSystems and Integration DeveloperCommented:
I assume that ActiveProject is essentially one member of the Projects collection. Is that right ?

If so, why not just make ActiveProject a method of the Application object, and have it return the correct item from the Projects collection.

i.e.

    '// Application class
    Private m_oProjects As cProjects             '// Object representing Projects collection (contains collection of cProject objects)
    Private m_iActiveProject As Integer          '// Stores index of active project
 
    Public Function ActiveProject() As cProject
        '// Returns currently active project object
        ActiveProject = m_oProjects.Item(m_iActiveProject)
    End Function
   

Hope this helps.
0
 
VBTechpapiAuthor Commented:
The implementation looks fine, but I'm wondering how to set m_iActiveProject to the active project.
0
All Courses

From novice to tech pro — start learning today.