I have been debugging my for loop and I have found that it does not progress through the code it gets to a certain line runs the line comes back to that line once its run and runs it again therefore causing the following error.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Here's my for loop:
For Each user As Data.DataRow In userData.Rows
If user Is Nothing Then
Exit For
End If
memberList(userId) = New clsMember(user("UserID"), user("Firstname"), user("Secondname"), user("Username"), user("Password"), user("Email"), user("Rights"))
userId += 1
Next
The line it gets stuck on is the following:
memberList(userId) = New clsMember(user("UserID"), user("Firstname"), user("Secondname"), user("Username"), user("Password"), user("Email"), user("Rights"))
Whilst debugging I found it runs the first time perfectly comes back around to the for loop tries to run it again without getting to the next line:
userId += 1
And causes the error, I have no idea at all why it is doing this.
If you need any more code I will be happy to provide it.