Excel VBA: How do I add an item to a collection within a class? -


i have class contains collection of itself. (the top level class contains summary versions of detailed instances in collection.)

currently collection public variable because haven't figured out details of working private variables yet. can fix later.

how add items collection? getting error 91 missing object variables.

thanks prior help. have been retooling code use classes more extensively, , it's great how things cleaning up.

class cpe

public pe_details collection ' collection of cpe public pe_id integer public pe_id_index integer  ' add detailed list of pe's public function addpedetail(byref cpe_detail cpe)      pe_details.add cpe_detail    ' error: object variable or                                   ' block variable not set  end function 

the module code calls follows:

dim clspe cpe                ' summary version of pe dim clspe_detail cpe         ' detailed pe dim integer  set clspe = new cpe     ' pe contain list of detailed pes  ' add 3 instances of detailed cpe summary cpe object = 1 3    set clspe_detail = new cpe     clspe_detail.pe_id = clspe.pe_id    clspe_detail.pe_id_index = clspe.pe_id_index    'etc.     clspe.addpedetail clspe_detail  ' see above next 

in cpe class add method class_initialize , initialize variables. have never set pe_details null/nothing

private sub class_initialize()  set pe_details = new collection  end sub 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -