Aggregation and composition are implemented in the same way in VB. This is because unlike some languages such as C++, you cannot physically contain one VB object within another. However VB does allow you to achieve a similar effect by ensuring your composed objects are created at the same time. We achieve this by adding the 'new' keyword to the Private variable that holds the sub-object:
'My engine - this will be created when I get created Dim m_theEngine As New Engine
'code for class..
Was this article helpful?