excel - Adding Objects as items to Collection Instance -
i have "instrument
" class defined several properties shall collected in "instruments
" class collection of "instrument
" classes.
the problem: collection not consist of "instrument
"-items of collection of "instrument"-items. made "homework" (i.e. searching hours), appreciate if give me hint:
in main sub create instance of collection , fill it:
sub create_instruments() dim instruments new ea_instruments ' read info db instruments.fillfromdb end sub
ea_instruments collection class
private m_colinstruments collection private sub class_initialize() set m_colinstruments = new collection end sub
within instruments utilize method fill collection:
public sub fillfromdb() ' read info database dim aedata() variant aedata = worksheets("ae db").listobjects("ae_data").databodyrange.value dim db_row, db_rows long db_rows = ubound(aedata, 1) ' instruments info array dim addinstrument ea_instrument db_row = 1 db_rows set addinstrument = new ea_instrument ' read , add together properties 'with addinstrument addinstrument.source = aedata(db_row, source_col) addinstrument.entity = aedata(db_row, entity_col) . . . addinstrument.mv = aedata(db_row, mv_col) 'end me.add addinstrument next db_row end sub
where add together method defined as:
public sub add(addinstrument ea_instrument) m_colinstruments.add addinstrument end sub
could please give me hint code flawed!?
excel vba object collections add
No comments:
Post a Comment