martialarts
Regular
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
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:
Thanks!
Code:
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:
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!