Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

number of indicies less than dimensions in array

Status
Not open for further replies.

Maven4Champ

Technical User
Jun 16, 2004
154
0
0
All,

Receiving this error when trying to declare, and add to a dynamic array. I may be doing this wrong because arrays aren't my speciality AT ALL.

Here is the code I have so far:
Code:
        Dim x As Integer = 0
        Dim excluded As String()


                Dim excludedList As New ArrayList()
                For Each dr As DataRowView In dv1
                    excludedList.Add(dv1.Table.Rows(x).Item(0).ToString())
                    x = x + 1
                Next

        excluded() = CType(excludedList.ToArray(GetType(String)), String())

Just as an FYI, dr and dv1 are already declared in earlier code. I am trying to just loop through the records and add to the array. The MSDN article(s) I found weren't much help so I am coming to the pros.

Let me know if you can assist.
Thanks!
 
I think this should rather be posted in forum796

Not that i unnerstand much of the nettish stuff, but shouldn't it look more like this? (Perhaps using column name?)

[tt] excludedList.Add(dr.Item(0).ToString())
' or
excludedList.Add(dr("NameOfColumn").ToString())
' or
excludedList.Add(CType(dr("NameOfColumn"), String))[/tt]

But again, better take the question to forum796.

Roy-Vidar
 
Whoops - I got to "click" happy. I have it adding rows into the array now with my original syntax not using the last line of code. I will now need to figure out why its erroring out with no row at position "xx"

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top