Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Leon Hansen   on Nov 26 In MS Office Category.

  
Question Answered By: Juan Reynolds   on Nov 26

Try this...

Code for Class Module "Unit":

'Public array  not allowed in class module, so use private
'array with let and get properties
Private GV(1 To 25)
Property Let GenValues(index, value)
GV(index) = value
End Property
Property Get GenValues(index)
GenValues = GV(index)
End Property

Code in regular module:

Dim Units As New Collection
Sub TestU()
'create a new unit
Set MyUnit = New Unit
'fill in some GenValues
For i = 1 To 25
MyUnit.GenValues(i) = i ^ 2
Next
Units.Add MyUnit
'create another new unit
Set MyUnit = New Unit
'fill in some more GenValues
For i = 1 To 25
MyUnit.GenValues(i) = i ^ 3
Next
Units.Add MyUnit
'access the GenValues
x = Units(1).GenValues(2)
y = Units(2).GenValues(2)
End Sub

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Help with Objects and Nested Collections Or get search suggestion and latest updates.


Tagged: