How to set an array to a list of values in VB.NET?

Posted by IPX Ares on Stack Overflow See other posts from Stack Overflow or by IPX Ares
Published on 2010-04-08T18:22:01Z Indexed on 2010/04/08 18:23 UTC
Read the original article Hit count: 387

Filed under:
|

I cannot figure out how to set an array to one of two sets of numbers (there will be more later), every way that I have tried throws some kind of error. I have tried to Dim the array inside the case statements, but then I cannot use the array in the For Each, which makes this worthless.... any ideas would be appreciated.

Code:

        Dim HourArray() As Integer

        Select Case CurrentShapeRow(ROW_PERIOD)
            Case "ON", "2X16"
                HourArray = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21}
            Case "2X8", "5X8"
                HourArray = {0, 1, 2, 3, 4, 5, 22, 23}
            Case Else
                Throw New Exception(String.Format("Unhandled Period: {0}", CurrentShapeRow(ROW_PERIOD)))
        End Select


        For Each HourCount As Integer In HourArray()
             'DO SOME STUFF HERE
        Next

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about arrays