views:

36

answers:

3

Here is the structure that I have:

Friend Class StandardFormatFile
    Friend fileType As String
    Friend numberOfSeries As Integer
    Friend standardSeriesData As New ArrayList

End Class

Friend Class StandardFormatFileSeries

    Friend standardNumOfElements As Integer
    Friend standardSeriesName As String
    Friend standardDataElements As New ArrayList

End Class

Friend Class StandardFormatFileElement
    Friend standardX_TimeValue As Single
    Friend standardY_SampleValue As Single

End Class

Now, here is the code implementing it:

   ReDim Preserve firstFile.standardSeriesData(firstFile.numberOfSeries - 1)

    For i As Integer = 0 To firstFile.numberOfSeries - 1
        Try

            firstFile.standardSeriesData(i).standardSeriesName = GetSeriesName(file1BReader)
            secondFile.standardSeriesData(i).standardNumOfElements = GetSeriesName(file2BReader)

            ReDim Preserve firstFile.standardSeriesData(i).standardDataElements(firstFile.standardSeriesData(i).standardNumOfElements)

            For j As Integer = 0 To firstFile.standardSeriesData(i).standardNumOfElements - 1
                firstFile.standardSeriesData(i).standardDataElements(j).standardX_TimeValue = file1BReader.ReadSingle
                firstFile.standardSeriesData(i).standardDataElements(j).standardY_SampleValue = file1BReader.ReadSingle

                secondFile.standardSeriesData(i).standardDataElements(j).standardX_TimeValue = file2BReader.ReadSingle
                secondFile.standardSeriesData(i).standardDataElements(j).standardY_SampleValue = file2BReader.ReadSingle
            Next

        Catch ex As Exception
            MsgBox(ex.Message & " *** i = " & i)
        End Try

    Next

I dont know why I am getting the error I am getting the error. I am ReDim'ing...shouldnt that work? Ive tried Arraylists and List(of object) and that doesnt work correctly.

help... stuck!

+1  A: 

Wouldn't your first line be Redimming to -1 since firstFile.numberOfSeries would eval to 0?

Tahbaza
You are right... iw as cutting and pasting to something that was close to what i started out with. I am going to try the above stated way and post back thanks.
Sean P
+1  A: 

It's an arraylist, don't redim, just add.

Plus

You should defenitely use generics

Friend Class StandardFormatFile
    Friend fileType As String
    Friend numberOfSeries As Integer
    Friend standardSeriesData As New List(of StandardFormatFileSeries)

End Class

Friend Class StandardFormatFileSeries

    Friend standardNumOfElements As Integer
    Friend standardSeriesName As String
    Friend standardDataElements As New List(of StandardFormatFileElement)

End Class

Friend Class StandardFormatFileElement
    Friend standardX_TimeValue As Single
    Friend standardY_SampleValue As Single

End Class

And again, it's a data structure that's contained in an object, not an Array. So use add instead of redim.

Cheers !

Alex Rouillard
A: 

Ok so i figured it out... such a rookie move. I dont know why i couldnt figure this out alone. I was on the right route... i just had a brain fart:

 For i As Integer = 0 To firstFile.numberOfSeries - 1

        Dim tempSeriesData1 As New StandardFormatFileSeries
        Dim tempSeriesData2 As New StandardFormatFileSeries

        tempSeriesData1.standardNumOfElements = file1BReader.ReadInt32
        tempSeriesData1.standardSeriesName = GetSeriesName(file1BReader)

        tempSeriesData2.standardNumOfElements = file2BReader.ReadInt32
        tempSeriesData2.standardSeriesName = GetSeriesName(file2BReader)


        For j As Integer = 0 To tempSeriesData1.standardNumOfElements - 1
            Dim tempElementData1 As New StandardFormatFileElement
            Dim tempElementData2 As New StandardFormatFileElement

            tempElementData1.standardX_TimeValue = file1BReader.ReadSingle
            tempElementData1.standardY_SampleValue = file1BReader.ReadSingle
            tempElementData2.standardX_TimeValue = file2BReader.ReadSingle
            tempElementData2.standardY_SampleValue = file2BReader.ReadSingle

            tempSeriesData1.standardDataElements.Add(tempElementData1)
            tempSeriesData2.standardDataElements.Add(tempElementData2)


        Next

        firstFile.standardSeriesData.Add(tempSeriesData1)
        secondFile.standardSeriesData.Add(tempSeriesData2)


    Next
Sean P