Solved

vb 2008 sortedlist within a structure

Posted on 2014-10-06
2
138 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

808 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