Solved

vb 2008 sortedlist within a structure

Posted on 2014-10-06
2
140 Views
Last Modified: 2014-10-06
"Object reference not set to an instance of an object" is the error I receive. Usually I declare these with the NEW qualifier, but that was not allowed in a structure.

 Private Structure slArray
        Dim ProviderandCases As SortedList
        Dim ProviderandCharges As SortedList
        Dim PayerPrimaryandCharges As SortedList
        Dim PayerPrimaryandCases As SortedList
        Dim MDandNonMDCharges As SortedList
        Dim MDandNonMDCases As SortedList
        Dim MDandNonMDMedicareFFS01Charges As SortedList
        Dim MDandNonMDMedicareFFS01Cases As SortedList
    End Structure
    Private slTotalsTable(13) As slArray   ' 0 will be Totals, 1- 12 will be months

' this is in a subroutine
            For ii As Integer = 0 To 12
                slTotalsTable(ii).ProviderandCases.Clear()
                slTotalsTable(ii).ProviderandCharges.Clear()
                slTotalsTable(ii).PayerPrimaryandCharges.Clear()
                slTotalsTable(ii).PayerPrimaryandCases.Clear()
                slTotalsTable(ii).MDandNonMDCharges.Clear()
                slTotalsTable(ii).MDandNonMDCases.Clear()
                slTotalsTable(ii).MDandNonMDMedicareFFS01Charges.Clear()
                slTotalsTable(ii).MDandNonMDMedicareFFS01Cases.Clear()
            Next

Open in new window

0
Comment
Question by:JamesDBuskirk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 40365104
First of all, structures should be small objects. Look at the structures in the framework, they all have only a few numerical properties. Microsoft suggest a maximum of 16 bytes to be efficient.

You structure holds 8 pointers. Depending if you are in 32-bits or 64-bits, this compiles to twice of four times the recommended size.

Using a class might be more appropriate.

And at the same time, it would enable you to instantiate (call new) your SortedList objects, since New is permitted in a class.

Use your class the same way you would use your structure, except that for a class, you need to call New on the class itself before you use it.
0
 

Author Comment

by:JamesDBuskirk
ID: 40365111
Excellent, thank you!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question