Building a multidimensional array in vb.net

前端 未结 5 1890
离开以前
离开以前 2020-12-10 05:30

I\'m trying to build up a multidimensional array which will hold two bits of info for each record in a database e.g. id, description.

This is what I am currently doi

5条回答
  •  萌比男神i
    2020-12-10 05:59

    The problem is that you are not initializing the array.

    This should work, until i will not reach the limits set in the initialization.

    Dim mArray(100,100) As String
    Dim i As Integer = 0
    While cmdReader.Read()
        mArray(i,0) = cmdReader.Item("id")
        mArray(i,1) = cmdReader.Item("description")
        i = i + 1
    End While
    

    But if the array limits are not known I suggest to follow astander's suggestion.

提交回复
热议问题