Solved

vb 2008 sortedlist within a structure

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

732 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