VBA Class : Collection.item member is a collection . How to retrieve sub collection item elements -


i have template data

header of file ((string1, string2...) group1 header (string1, string2...) group1/line1 (string1, string2...) group1/line2 (string1, string2...) group2 header (string1, string2...) group2/line1 (string1, string2...) group2/line2 (string1, string2...)

note : datas belonging group header , group line different type if on same 'coloumn' (raw data comes text file)

i create main class (populate collection) , data class (populate item : cdata_nomination), works individualy need create :

-1 file collection (i have multiples files) store -- fields (file header) , -- x sub collection (groups) wich store --- fields (group header) --- x sub collection store ---- fields (line data)

in folowing code on line 170 .odpo group collection every data store on collection property let (....). seem store !

public function nomcreate(m_sfilepath string, m_objdatalist() string, m_cldpo collection) cdata_nomination  10        on error goto err_handler           dim functions new cfunctions           dim objresult cdata_nomination           dim objdate() string          'note : init var(s) /object(s)       '----------------------------  20        set objresult = new cdata_nomination  30        objresult 40            .filename = functions.string_nz(m_sfilepath) 50            .datasource = functions.string_nz(m_objdatalist(1)) 60            .delres = functions.string_nz(m_objdatalist(2)) 70            .datetime = functions.date_nz(m_objdatalist(4) & " " & m_objdatalist(5) & ":00") 80            objdate = split(replace(m_objdatalist(6), " - ", "-"), "-") 90            .datetimerange_start = functions.date_nz(objdate(0)) 100           .datetimerange_end = functions.date_nz(objdate(1)) 110           .sender = functions.string_nz(m_objdatalist(7)) 120           .receiver = functions.string_nz(m_objdatalist(8)) 130           .gaspointname = functions.string_nz(m_objdatalist(9)) 140           .gaspointnameexternal = functions.string_nz(m_objdatalist(10)) 150           .description = functions.string_nz(m_objdatalist(11)) 160           .datatype = functions.string_nz(m_objdatalist(12)) 170           .odpo = dpo 180       end  err_exit:           'note : return function value 190       set nomcreate = objresult           'note : delete object 200       set objresult = nothing           'note : exit 210       exit function  err_handler:           'note : exit function 220       goto err_exit 

when try read data got problem can't access collection .odo via property (see following code)

'property belonging class cdata_nomination public property let odpo(byval ocollection collection)     dim m_odpo new collection     set m_odpo = ocollection end property 

how can pass collection existing item collection (i might have been wrong) , how can retrieve sub collection items main collection ?

i hope it's clear ...

thanks in advance

class cnum (extract of parent)

private m_sfilename string private odpo collection  private sub class_initialize()   set odpo = new collection end sub  public property filename() string     filename = m_sfilename     end property  public property let filename(byval sfilename string)     m_sfilename = sfilename     end property  public property dpo() collection     set dpo = odpo     end property  public property set dpoadd(dpocollection collection)     dim dpoitem         each dpoitem in dpocollection             odpo.add dpoitem             next     end property 

class cdop (child of parent)

private m_sdelivery string private oqty collection  private sub class_initialize()   set oqty = new collection end sub  public property delivery() string     delivery = m_sdelivery end property  public property let delivery(byval sdelivery string)     m_sdelivery = sdelivery end property   public property qty() collection     set qty = oqty end property  public property set qtyadd(qtycollection collection)     dim qtyitem         each qtyitem in qtycollection         oqty.add qtyitem     next end property 

class cqty (sub child)

private m_sstatus string  public property status() string     status = m_sstatus end property  public property let status(byval sstatus string)     m_sstatus = sstatus end property 

regular module

sub mymodule()      dim long     dim j long     dim k long     dim cnum cnum     dim cdpo cdpo     dim cqty cqty     dim onum collection     dim odpo collection     dim oqty collection      set onum = new collection     = 1 3         set cnum = new cnum         cnum.filename = "file " &          set odpo = new collection         j = 1 3             set cdpo = new cdpo             cdpo.qty = "qty" & & j             cdpo.delivery = "delivery " & & j              set oqty = new collection              k = 1 3                 set cqty = new cqty                 cqty.statut = "ok_" & & "-" & j & "-" & k                 oqty.add cqty                             next k              set cdpo.qtyadd = oqty                      odpo.add cdpo          next j          set cnum.dpoadd = odpo         onum.add cnum      next      'set odpo = nothing     '      each cnum in onum         debug.print ""         debug.print "---------file ----------------"         debug.print ""         debug.print "-[num] " & cnum.filename & " | " & cnum.info         set odpo = cnum.dpo         each cdpo in odpo             debug.print "--[dpo] " & cdpo.counterpart & " | " & cdpo.delivery              set oqty = cdpo.qty             each cqty in oqty                 debug.print "---[qty] " & cqty.quantity & " | " & cqty.statut             next         next      next  end sub 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -