creating vs. defining an array

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vacuit
    New Member
    • Aug 2007
    • 3

    #1

    creating vs. defining an array

    I am getting the Error: Object reference not set to an instance of an object. for this code:

    Class udtYear
    Public N As Long 'total population size
    ...
    End Class

    Class udtRun
    Public Yr(0 To PROJYR - MINYR) As udtYear 'year -1 of model simulation
    End Class

    Sub CrustaceanIBM()
    ...
    Dim SimRun(0 To NumRuns - 1) As udtRun 'output of each simulation run
    ...
    SimRun(r).Yr(0) .N = N0

    however I can't assign SimRun As NEW udtrun because SimRun is an array.

    Any suggestions?

    thanks
    Amanda
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by vacuit
    Dim SimRun(0 To NumRuns - 1) As udtRun 'output of each simulation run
    SimRun(r).Yr(0) .N = N0
    however I can't assign SimRun As NEW udtrun because SimRun is an array.

    Any suggestions?
    How about...
    Set SimRun(0) = New udtRun
    and similarly for each occurrence of the array?
    (I have no idea whether this will work.)

    Comment

    Working...