Solved

vb 2008 sortedlist within a structure

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now