?
Solved

Creating Object Models in VB

Posted on 2004-07-30
3
Medium Priority
?
235 Views
Last Modified: 2013-12-04
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?
0
Comment
Question by:VBTechpapi
[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
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 11683544
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
 

Author Comment

by:VBTechpapi
ID: 11711617
The implementation looks fine, but I'm wondering how to set m_iActiveProject to the active project.
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 750 total points
ID: 11712824
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Make the most of your online learning experience.
Simple Linear Regression
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

752 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