martialarts Posted January 6, 2006 Posted January 6, 2006 I am trying to create a structure that contains an arraylist of another structure. As far as I know an arraylist can be a member of a structure and an arraylist can contain any object, including another structure... so I don't know what the problem is. The compiler is stopping on results.elementArray.Add(elementInfo) and saying: "An unhandled exception of type 'System.NullReferenceException' occurred in application.exe Additional information: Object reference not set to an instance of an object." I think it is upset about elementArray. Can anyone offer any advice? Here is the code: Module ModuleParse Structure elementStruct Public name As String Public clinicalLow As Decimal Public clinicalHigh As Decimal Public value As String End Structure Structure resultsStruct Public patientID As String Public lastName As String Public firstName As String Public gender As String Public birthdate As String Public weight As String Public bloodType As String Public dateDrawn As String Public elementArray As ArrayList End Structure Function parseResults(ByRef results As resultsStruct) Dim elementInfo As elementStruct results.patientID = "123456" elementInfo.name = "Nitrogen" elementInfo.clinicalLow = 44 elementInfo.clinicalHigh = 51.7 results.elementArray.Add(elementInfo) Return results End Function End Module Thanks! Quote
martialarts Posted January 6, 2006 Author Posted January 6, 2006 Got it I found my problem. I was missing this: results.elementArray = New ArrayList I added it after setting results.patientID and this fixed it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.