Array of class objects as class member in VBA

前端 未结 2 1375
温柔的废话
温柔的废话 2021-01-13 03:37

I\'m writing an Excel macro in VBA to send emails to library patrons alerting them of overdue materials. The data comes from a spreadsheet with data like

Use         


        
2条回答
  •  孤街浪徒
    2021-01-13 04:34

    Per my comment I would use a collection. Here is how you define it and initialize it

    Public book_list As Collection
    
    'intitalize the collection in the constructor of the class
    Private Sub Class_Initialize()
        Set book_list = New Collection
    End Sub
    

    and to use it

    book_list.Add 
    dim bk as Book
    set bk  = book_list.Item(indexNumber)
    

提交回复
热议问题